/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum, a[N6];
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		cin >> a[i];
		u[a[i]] = 1;
	}

	int N = (int)1e6;

	forn(i, 1, n){
		if(u[N - a[i] + 1])
			sum += a[i] - 1;
		else{
			u[N - a[i] + 1] = 1;
			ans.pb(N - a[i] + 1);
		}
	}

	forn(i, 1, N){
		if(u[i] || sum - (N - i) - i + 1 < 0)
			continue;
		sum -= (N - i) - i + 1;
		ans.pb(i);
		ans.pb(N - i + 1);
	}

	assert(sum == 0);

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,val) ((c).find(val) != (c).end())
#define cpresent(c,val) (find(all(c),val) != (c).end())
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, x, y) for(int i= (x); i<= (y); ++i)
#define FORR(i, y, x) for(int i= (y); i>= (x); --i)

#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()
#define debug(var) cerr<<#var<<" = "<<(var)<<endl;
#define debugarr(var,n) cerr<<#var<<" = { ";rep(i,n) cerr<<var[i]<<" ";cerr<<"}"<<endl;
#define debugmat(var,m,n) cerr<<#var<<" = \n";rep(i,m) {rep(j,n) cerr<<var[i][j]<<" ";cerr<<endl;}
#define sci(var) scanf("%d",&(var))
#define scll(var) scanf("%lld",&(var))
#define MOD ((int)1e9+7)

bool b[1000005];

int main() {
	int n;cin>>n;
	int s=1000000;
	set<int> X;
	while(n--) {
		int x;cin>>x;
		X.insert(x);
	}
	set<int> ans;
	int num=0;
	for(set<int>::iterator it=X.begin();it!=X.end();it++) {
		set<int>::iterator it1=X.find(s+1-*it);
		if(it1==X.end()) {ans.insert(s+1-*it);b[*it]=b[s+1-*it]=true;}
		else {
			num++;b[*it]=b[s+1-*it]=true;
		}
	}
	num/=2;
	int curr=0;
	while(num--) {
		while(1) {
			curr++;
			if(!b[curr] && !b[s+1-curr]) {
				ans.insert(curr);
				ans.insert(s+1-curr);
				break;
			}
		}
	}
	cout<<sz(ans)<<endl;
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,val) ((c).find(val) != (c).end())
#define cpresent(c,val) (find(all(c),val) != (c).end())
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, x, y) for(int i= (x); i<= (y); ++i)
#define FORR(i, y, x) for(int i= (y); i>= (x); --i)

#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()
#define debug(var) cerr<<#var<<" = "<<(var)<<endl;
#define debugarr(var,n) cerr<<#var<<" = { ";rep(i,n) cerr<<var[i]<<" ";cerr<<"}"<<endl;
#define debugmat(var,m,n) cerr<<#var<<" = \n";rep(i,m) {rep(j,n) cerr<<var[i][j]<<" ";cerr<<endl;}
#define sci(var) scanf("%d",&(var))
#define scll(var) scanf("%lld",&(var))
#define MOD ((int)1e9+7)

bool b[1000005];

int main() {
	int n;sci(n);
	int s=1000000;
	set<int> X;
	while(n--) {
		int x;sci(x);
		X.insert(x);
	}
	set<int> ans;
	int num=0;
	for(set<int>::iterator it=X.begin();it!=X.end();it++) {
		set<int>::iterator it1=X.find(s+1-*it);
		if(it1==X.end()) {ans.insert(s+1-*it);b[*it]=b[s+1-*it]=true;}
		else {
			num++;b[*it]=b[s+1-*it]=true;
		}
	}
	num/=2;
	int curr=0;
	while(num--) {
		while(1) {
			curr++;
			if(!b[curr] && !b[s+1-curr]) {
				ans.insert(curr);
				ans.insert(s+1-curr);
				break;
			}
		}
	}
	printf("%d\n", sz(ans));
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) printf("%d ", *it);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,val) ((c).find(val) != (c).end())
#define cpresent(c,val) (find(all(c),val) != (c).end())
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, x, y) for(int i= (x); i<= (y); ++i)
#define FORR(i, y, x) for(int i= (y); i>= (x); --i)

#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()
#define debug(var) cerr<<#var<<" = "<<(var)<<endl;
#define debugarr(var,n) cerr<<#var<<" = { ";rep(i,n) cerr<<var[i]<<" ";cerr<<"}"<<endl;
#define debugmat(var,m,n) cerr<<#var<<" = \n";rep(i,m) {rep(j,n) cerr<<var[i][j]<<" ";cerr<<endl;}
#define sci(var) scanf("%d",&(var))
#define scll(var) scanf("%lld",&(var))
#define MOD ((int)1e9+7)

int main() {
	int n;cin>>n;
	int s=1000000;
	set<int> X;
	while(n--) {
		int x;cin>>x;
		X.insert(x);
	}
	set<int> ans;
	int num=0;
	for(set<int>::iterator it=X.begin();it!=X.end();it++) {
		set<int>::iterator it1=X.find(s+1-*it);
		if(it1==X.end()) ans.insert(s+1-*it);
		else {
			X.erase(it1);
			num++;
		}
	}
	int curr=0;
	while(num--) {
		while(1) {
			curr++;
			if(X.find(curr)!=X.end()) {
				ans.insert(curr);
				ans.insert(s+1-curr);
				break;
			}
		}
	}
	cout<<sz(ans)<<endl;
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,val) ((c).find(val) != (c).end())
#define cpresent(c,val) (find(all(c),val) != (c).end())
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, x, y) for(int i= (x); i<= (y); ++i)
#define FORR(i, y, x) for(int i= (y); i>= (x); --i)

#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()
#define debug(var) cerr<<#var<<" = "<<(var)<<endl;
#define debugarr(var,n) cerr<<#var<<" = { ";rep(i,n) cerr<<var[i]<<" ";cerr<<"}"<<endl;
#define debugmat(var,m,n) cerr<<#var<<" = \n";rep(i,m) {rep(j,n) cerr<<var[i][j]<<" ";cerr<<endl;}
#define sci(var) scanf("%d",&(var))
#define scll(var) scanf("%lld",&(var))
#define MOD ((int)1e9+7)

int main() {
	int n;cin>>n;
	int s=1000000;
	set<int> X;
	while(n--) {
		int x;cin>>x;
		X.insert(x);
	}
	set<int> ans;
	int num=0;
	for(set<int>::iterator it=X.begin();it!=X.end();it++) {
		set<int>::iterator it1=X.find(s+1-*it);
		if(it1==X.end()) ans.insert(s+1-*it);
		else {
			num++;
		}
	}
	num/=2;
	int curr=0;
	while(num--) {
		while(1) {
			curr++;
			if(X.find(curr)==X.end() && X.find(s+1-curr)==X.end()) {
				ans.insert(curr);
				ans.insert(s+1-curr);
				break;
			}
		}
	}
	cout<<sz(ans)<<endl;
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,val) ((c).find(val) != (c).end())
#define cpresent(c,val) (find(all(c),val) != (c).end())
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, x, y) for(int i= (x); i<= (y); ++i)
#define FORR(i, y, x) for(int i= (y); i>= (x); --i)

#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()
#define debug(var) cerr<<#var<<" = "<<(var)<<endl;
#define debugarr(var,n) cerr<<#var<<" = { ";rep(i,n) cerr<<var[i]<<" ";cerr<<"}"<<endl;
#define debugmat(var,m,n) cerr<<#var<<" = \n";rep(i,m) {rep(j,n) cerr<<var[i][j]<<" ";cerr<<endl;}
#define sci(var) scanf("%d",&(var))
#define scll(var) scanf("%lld",&(var))
#define MOD ((int)1e9+7)

int main() {
	int n;cin>>n;
	int s=1000000;
	set<int> X;
	while(n--) {
		int x;cin>>x;
		X.insert(x);
	}
	set<int> ans;
	int num=0;
	for(set<int>::iterator it=X.begin();it!=X.end();it++) {
		set<int>::iterator it1=X.find(s+1-*it);
		if(it1==X.end()) ans.insert(s+1-*it);
		else {
			X.erase(it1);
			num++;
		}
	}
	int curr=0;
	while(num--) {
		while(1) {
			curr++;
			if(X.find(curr)==X.end()) {
				ans.insert(curr);
				ans.insert(s+1-curr);
				break;
			}
		}
	}
	cout<<sz(ans)<<endl;
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
	return 0;
}


// https://codeforces.com/contest/405/problem/D

#include <bits/stdc++.h>
using namespace std;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

const int maxv = 1e6;
bool a[maxv+500];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        a[x-1] = true;
    }

    int pairs = 0;
    vector<int> ans;

    for(int i = 0; i < 1e6; i++) {
        if(i <= 10) {
            cerr << "inv of " << i << " is " << maxv-i << endl;
        }
        if(a[i] and a[maxv-i]) {
            pairs++;
        } else if(a[i]) {
            ans.emplace_back(maxv-i);
        }
    }

    watch(pairs)
    pairs /= 2;

    for(int i = 0; i < 1e6 and pairs; i++) {
        if(!a[i] and !a[maxv-i]) {
            ans.emplace_back(i);
            ans.emplace_back(maxv);
            pairs--;
        }
    }

    cout << sz(ans) << endl;
    for(int x: ans) {
        cout << x << " ";
    }
    cout << endl;
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


// https://codeforces.com/contest/405/problem/D

#include <bits/stdc++.h>
using namespace std;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

const int maxv = 1e6;
bool a[maxv+500];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        a[x-1] = true;
    }

    int pairs = 0;
    vector<int> ans;

    for(int i = 0; i < 1e6; i++) {
        if(a[i] and a[maxv-i-1]) {
            pairs++;
        } else if(a[i]) {
            ans.emplace_back(maxv-i);
        }
    }

    watch(pairs)
    pairs /= 2;

    for(int i = 0; i < 1e6 and pairs; i++) {
        if(!a[i] and !a[maxv-i-1]) {
            ans.emplace_back(i);
            ans.emplace_back(maxv-i-1);
            pairs--;
        }
    }

    cout << sz(ans) << endl;
    for(int x: ans) {
        cout << x << " ";
    }
    cout << endl;
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


// https://codeforces.com/contest/405/problem/D

#include <bits/stdc++.h>
using namespace std;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

const int maxn = (int)5e5+500;

int a[maxn];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    set<int> S;
    int need = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        S.emplace(a[i]);
        need += a[i]-1;
    }
    watch(need)
    vector<int> ans;
    for(int i = 1; 1 <= 1e6; i++) {
        int ree = (1e6) - i;
        if((ree <= need) and !S.count(i)) {
            cerr << "using " << i << endl;
            need -= ree;
            watch(need)
            ans.emplace_back(i);
            break;
        }
    }

    cout << sz(ans) << endl;
    for(int x: ans) {
        cout << x << " ";
    }
    cout << endl;
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


// https://codeforces.com/contest/405/problem/D

#include <bits/stdc++.h>
using namespace std;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

const int maxv = 1e6;
bool a[maxv+500];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        a[x-1] = true;
    }

    int pairs = 0;
    vector<int> ans;

    for(int i = 0; i < 1e6; i++) {
        if(a[i] and a[maxv-i-1]) {
            pairs++;
        } else if(a[i]) {
            ans.emplace_back(maxv-i-1);
        }
    }

    watch(pairs)
    pairs /= 2;

    for(int i = 0; i < 1e6 and pairs; i++) {
        if(!a[i] and !a[maxv-i-1]) {
            ans.emplace_back(i);
            ans.emplace_back(maxv-i-1);
            pairs--;
        }
    }

    cout << sz(ans) << endl;
    for(int x: ans) {
        cout << x << " ";
    }
    cout << endl;
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


// https://codeforces.com/contest/405/problem/D

#include <bits/stdc++.h>
using namespace std;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

const int maxv = 1e6;
bool a[maxv+500];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        a[x-1] = true;
    }

    int pairs = 0;
    vector<int> ans;

    for(int i = 0; i < 1e6; i++) {
        if(i <= 10) {
            cerr << "inv of " << i << " is " << maxv-i << endl;
        }
        if(a[i] and a[maxv-i]) {
            pairs++;
        } else if(a[i]) {
            ans.emplace_back(maxv-i);
        }
    }

    watch(pairs)
    pairs /= 2;

    for(int i = 0; i < 1e6 and pairs; i++) {
        if(!a[i] and !a[maxv-i]) {
            ans.emplace_back(i);
            ans.emplace_back(maxv-i);
            pairs--;
        }
    }

    cout << sz(ans) << endl;
    for(int x: ans) {
        cout << x << " ";
    }
    cout << endl;

    for(int x: ans) {
        cerr << x << " contributes " << (1e6-x) << endl;
    }
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


// https://codeforces.com/contest/405/problem/D

#include <bits/stdc++.h>
using namespace std;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

const int maxv = 1e6;
bool a[maxv+500];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        a[x] = true;
    }

    int pairs = 0;
    vector<int> ans;

    for(int i = 1; i <= 1e6; i++) {
        if(i <= 10) {
            cerr << "inv of " << i << " is " << maxv-i+1 << endl;
        }
        if(a[i] and a[maxv-i+1]) {
            pairs++;
        } else if(a[i]) {
            ans.emplace_back(maxv-i+1);
        }
    }

    watch(pairs)
    pairs /= 2;

    for(int i = 1; i <= 1e6 and pairs; i++) {
        if(!a[i] and !a[maxv-i+1]) {
            ans.emplace_back(i);
            ans.emplace_back(maxv-i+1);
            pairs--;
        }
    }

    cout << sz(ans) << endl;
    for(int x: ans) {
        cout << x << " ";
    }
    cout << endl;

    for(int x: ans) {
        cerr << x << " contributes " << (1e6-x) << endl;
    }
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back
const int N=1000001;
bool av[N];
void solve()
{
    int n;cin>>n;
    int a[n];
    int x=0;
    memset(av,1,sizeof(av));
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        x+=(a[i]-1);
        av[a[i]]=0;
    }
    vector<int> ans;
    for(int i=0;i<n;i++)
    {
        int v=(N-1)-(a[i]-1);
        ans.pb(v);
    }
    cout<<ans.size()<<nl;
    for(auto it:ans)
        cout<<it<<" ";
    cout<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n];int s=1000001;
    bool f[s];memset(f,1,sizeof(f));
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[a[i]]=0;
    }
    bool chk[s];memset(chk,0,sizeof(chk));int c=0;
    vector<int> ans;
    for(int i=0;i<n;i++)
    {
        int v=(s-a[i]);
        if(f[v])
        {
            ans.pb(v);
            f[v]=0;
            chk[a[i]]=1;
        }
        else if(f[v]==0 && chk[a[i]]==0 && chk[v]==0)
        {
            chk[a[i]]=chk[v]=1;
            c++;
        }
    }
    if(c>0)
    {
        for(int i=1;i<s && c>0;i++)
        {
            if(f[i]==1 && f[s-i]==1)
            {
                c--;
                ans.pb(i);ans.pb(s-i);
                f[i]=f[s-i]=0;
            }
        }
    }
    cout<<ans.size()<<nl;
    for(auto it:ans)
        cout<<it<<" ";
    cout<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n];int s=1000001;
    bool f[s];memset(f,1,sizeof(f));
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[a[i]]=0;
    }
    bool chk[s];memset(chk,0,sizeof(chk));int c=0;
    vector<int> ans;
    for(int i=0;i<n;i++)
    {
        int v=(s-a[i]);
        if(f[v])
        {
            ans.pb(v);
            f[v]=0;
            chk[a[i]]=1;
        }
        else
        {
            chk[a[i]]=chk[v]=1;
            c++;
        }
    }
    if(c>0)
    {
        for(int i=1;i<s && c>0;i++)
        {
            if(f[i]==1 && f[s-i]==1)
            {
                c--;
                ans.pb(i);ans.pb(s-i);
                f[i]=f[s-i]=0;
            }
        }
    }
    cout<<ans.size()<<nl;
    for(auto it:ans)
        cout<<it<<" ";
    cout<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define loop(i,n) for(int i=0;i<n;i++)
int a[1000009];
int _hash[1000009];
std::vector<int> v;
int s=1000000,l=0;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		_hash[a[i]]=1;
	}

	for(int i=0;i<n;i++){
		if( _hash[s- a[i]+1 ] == 0){
			v.push_back(s-a[i]+1);
			l++;
		}
	}

	int p=1;
	for(int i=0;i<n-l;i++){
		if( _hash[p-1]==0 and _hash[ s-p+1 ]==0 ){
			v.push_back(p);
			v.push_back(s-p+1);
		}
		p++;
	}

	cout<<v.size()<<endl;

	for(auto it: v)
		printf("%d ",it);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define loop(i,n) for(int i=0;i<n;i++)
int a[1000009];
int _hash[1000009];
std::vector<int> v;
int s=1000000,l=0;

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        _hash[a[i]]=1;
    }

    for(int i=0;i<n;i++){
        if( _hash[s- a[i]+1 ] == 0){
            v.push_back(s-a[i]+1);
            _hash[s-a[i]+1]=1;
            l++;
        }
    }

    int p=1;
    while(v.size()!=n){
        if( _hash[p]==0 and _hash[ s-p+1 ]==0 and p != (s-p+1) ){
            v.push_back(p);
            v.push_back(s-p+1);
        }
        p++;
    }

    cout<<v.size()<<endl;

    for(auto it: v)
        printf("%d ",it);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define loop(i,n) for(int i=0;i<n;i++)
int a[1000009];
int _hash[1000009];
std::vector<int> v;
int s=1000000,l=0;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		_hash[a[i]]=1;
	}

	for(int i=0;i<n;i++){
		if( _hash[s- a[i]+1 ] == 0){
			v.push_back(s-a[i]+1);
			_hash[s-a[i]+1]=1;
			l++;
		}
	}

	int p=1;
	for(int i=0;i<n-l;i++){
		if( _hash[p-1]==0 and _hash[ s-p+1 ]==0 ){
			v.push_back(p);
			v.push_back(s-p+1);
		}
		p++;
	}

	cout<<v.size()<<endl;

	for(auto it: v)
		printf("%d ",it);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define loop(i,n) for(int i=0;i<n;i++)
int a[1000009];
int _hash[1000009];
std::vector<int> v;
int s=1000000,l=0;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		_hash[a[i]]=1;
	}

	for(int i=0;i<n;i++){
		if( _hash[s- a[i]+1 ] == 0){
			v.push_back(s-a[i]+1);
			_hash[s-a[i]+1]=1;
			l++;
		}
	}

	int p=1;
	while(v.size()!=n){
		if( _hash[p-1]==0 and _hash[ s-p+1 ]==0 ){
			v.push_back(p);
			v.push_back(s-p+1);
		}
		p++;
	}

	cout<<v.size()<<endl;

	for(auto it: v)
		printf("%d ",it);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define loop(i,n) for(int i=0;i<n;i++)
int a[1000009];
int _hash[1000009];
std::vector<int> v;
int s=1000000,l=0;

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        _hash[a[i]]=1;
    }

    for(int i=0;i<n;i++){
        if( _hash[s- a[i]+1 ] == 0){
            v.push_back(s-a[i]+1);
            _hash[s-a[i]+1]=1;
            l++;
        }
    }

    int p=1;
    while(v.size()!=n){
        if( _hash[p-1]==0 and _hash[ s-p+1 ]==0 and (p-1) != (s-p+1) ){
            v.push_back(p);
            v.push_back(s-p+1);
        }
        p++;
    }

    cout<<v.size()<<endl;

    for(auto it: v)
        printf("%d ",it);

    return 0;
}


//God & me
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define int long long
using namespace std;
template<class T,class L>bool smax(T&x,L y){return x<y?(x=y,1):0;}template<class T,class L>bool smin(T&x,L y){return x>y?(x=y,1):0;}
typedef pair<int,int> pii;
const int maxn=1e5+17,s=1e6;
int n;
bool mark[s+1];
random_device rd;
main(){
  ios::sync_with_stdio(0),cin.tie();
  cin>>n;
  int cnt=0;stringstream res;
  for(int i=0,x;i<n;i++){
    cin>>x,mark[x]=1;
    if(!mark[s-x+1]){
      res<<s-x+1<<' ';
      mark[s-x+1]=1;
      cnt++;
      continue;
    }
    int javad=rd()%s+1;
    while(mark[javad] || mark[s-javad+1])
      javad=rd()%s+1;
    mark[javad]=mark[s-javad+1]=1;
    res<<javad<<' '<<s-javad+1<<' ';cnt++;
  }
  cout<<cnt<<'\n'<<res.str()<<'\n';
  return 0;
}


//God & me
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define int long long
using namespace std;
template<class T,class L>bool smax(T&x,L y){return x<y?(x=y,1):0;}template<class T,class L>bool smin(T&x,L y){return x>y?(x=y,1):0;}
typedef pair<int,int> pii;
const int maxn=1e5+17,s=1e6;
int n;
bool mark[s+1];
random_device rd;
main(){
  ios::sync_with_stdio(0),cin.tie();
  cin>>n;
  int cnt=0;stringstream res;
  for(int i=0,x;i<n;i++){
    cin>>x,mark[x]=1;
    if(!mark[s-x+1]){
      res<<s-x+1<<' ';
      cnt++;
      continue;
    }
    int javad=rd()%s+1;
    while(mark[javad] || mark[s-javad+1])
      javad=rd()%s+1;
    res<<javad<<' '<<s-javad+1<<' ';cnt++;
  }
  cout<<cnt<<'\n'<<res.str()<<'\n';
  return 0;
}


//God & me
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define int long long
using namespace std;
template<class T,class L>bool smax(T&x,L y){return x<y?(x=y,1):0;}template<class T,class L>bool smin(T&x,L y){return x>y?(x=y,1):0;}
typedef pair<int,int> pii;
const int maxn=5e5+17,s=1e6;
int n,a[maxn];
bool mark[s+1];
random_device rd;
main(){
  ios::sync_with_stdio(0),cin.tie();
  cin>>n;
  int cnt=0;stringstream res;
  for(int i=0;i<n;i++)
    cin>>a[i],mark[a[i]]=1;
  for(int i=0;i<n;i++){
    int x=a[i];
    if(!mark[s-x+1]){
      res<<s-x+1<<' ';
      mark[s-x+1]=1;
      cnt++;
      continue;
    }
    int javad=rd()%s+1;
    while(mark[javad] || mark[s-javad+1])
      javad=rd()%s+1;
    mark[javad]=mark[s-javad+1]=1;
    res<<javad<<' '<<s-javad+1<<' ';cnt+=2;
  }
  cout<<cnt<<'\n'<<res.str()<<'\n';
  return 0;
}


//God & me
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define int long long
using namespace std;
template<class T,class L>bool smax(T&x,L y){return x<y?(x=y,1):0;}template<class T,class L>bool smin(T&x,L y){return x>y?(x=y,1):0;}
typedef pair<int,int> pii;
const int maxn=5e5+17,s=1e6;
int n,a[maxn];
bool mark[s+1],no[s+1];
random_device rd;
main(){
  ios::sync_with_stdio(0),cin.tie();
  cin>>n;
  int cnt=0;stringstream res;
  for(int i=0;i<n;i++)
    cin>>a[i],mark[a[i]]=1;
  for(int i=0;i<n;i++){
    int x=a[i];
    if(no[x])continue;
    if(!mark[s-x+1]){
      res<<s-x+1<<' ';
      mark[s-x+1]=1;
      cnt++;
      continue;
    }
    no[s-x+1]=1;
    int javad=rd()%s+1;
    while(mark[javad] || mark[s-javad+1])
      javad=rd()%s+1;
    mark[javad]=mark[s-javad+1]=1;
    res<<javad<<' '<<s-javad+1<<' ';cnt+=2;
  }
  cout<<cnt<<'\n'<<res.str()<<'\n';
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int S,n,a,f[1000010],pre=1;
int main()
{
	S=read(); n=read();
	for(int i=1;i<=n;i++)
		a=read(),f[a]=1;
	write(n); putchar('\n');
	for(int i=1;i<=S;i++)
		if(f[i]==1&&f[S-i+1]==0)write(S-i+1),putchar(' '),f[S-i+1]=2;
	for(int i=1;i<=S;i++)
	{
		if(f[i]==1&&f[S-i+1]==1)
		{
			for(int j=pre;j<=S;j++,pre++)
				if(f[j]==0&&f[S-j+1]==0)
				{
					write(j),putchar(' '),write(S-j+1),putchar(' ');
					f[j]=f[S-j+1]=2;
					break;
				}
		}
	}
	return 0;
}


#include <iostream>

using namespace std;
int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        i = gcd(c, gcd(a, b));
        if(a + b >= c)
            cout << (c + a) * i << endl;
        else
            cout << (c - a) - i << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;
int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        i = gcd(c, gcd(a, b));
        if(a + b >= c)
            cout << c + i;
        else
            cout << (b - a - 1) * i;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        if((b - a) == (c - b))
            cout << (b - a) + c << endl;
        else if((b - a) > (c - b))
            cout << (b - a) - (c - b) << endl;
        else
            cout << (b - a) + (c - b) << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int h = 0; h < t; h++){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(max(a, b), c) << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        cout << (b - a) + c << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        if(a + b > c)
            cout << b + 1 << endl;
        else
            cout << (b - a) + c << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;
int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        i = gcd(c, gcd(a, b));
        if(a + b >= c)
            cout << c + i;
        else
            cout << a + b - i;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        if(a + b >= c)
            cout << c + 1 << endl;
        else
            cout << b + 1 << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        cout << (a + b + c) / 3 << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        cout << (c - b) + a << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        cout << c + 1 << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        if(a + b >= c)
            cout << c + 1;
        else
            cout << a + b - 1;
    }
    return 0;
}


#include <iostream>

using namespace std;
int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        i = gcd(c, gcd(a, b));
        if(a + b >= c)
            cout << c + i << endl;
        else
            cout << (b - a - 1) * i << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for(int u = 0; u < t; u++){
        int a, b, c, i;
        cin >> a >> b >> c;
        cout << (c - (a + b)) + c << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    ll in[3];
    cin >> in[0] >> in[1] >> in[2];
    sort(in, in + 3);
    ll d = (ll)sqrt((in[2] - in[0]) * (in[2] - in[0]) - in[1] * in[1]);
    cout << d << endl;
  }
}


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    ll in[3];
    cin >> in[0] >> in[1] >> in[2];
    sort(in, in + 3);

    cout << in[1] << endl;
  }
}


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    ll in[3];
    cin >> in[0] >> in[1] >> in[2];
    sort(in, in + 3);
    ll d = (in[2] - in[0]) * (in[2] - in[0]) + (in[1] * in[1]);
    d = sqrt(d);
    cout << d << endl;
  }
}


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    ll in[3];
    cin >> in[0] >> in[1] >> in[2];
    sort(in, in + 3);
    ll d = (ll)sqrt((in[2] - in[0]) * (in[2] - in[0]) - in[1] * in[1]) + 1;
    cout << d << endl;
  }
}


#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    ll in[3];
    cin >> in[0] >> in[1] >> in[2];
    sort(in, in + 3);
    ll d = (ll)sqrt((ll)(in[2] - in[0]) * (in[2] - in[0]) - (ll)(in[1] * in[1])) + 1;
    cout << d << endl;
  }
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define si set<int>
#define usi set<int>
#define pb push_back
#define mp make_pair
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int arr[3];
		for(int i=0;i<3;i++){
			cin >> arr[i];
		}
		int a = arr[0] + arr[1];
		int b = arr[2];
		int ans = sqrt((b*b) + (a*a));
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define si set<int>
#define usi set<int>
#define pb push_back
#define mp make_pair
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int arr[3];
		for(int i=0;i<3;i++){
			cin >> arr[i];
		}
		int a = arr[0] + arr[1];
		int b = arr[2];
		cout << a+b+2 << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define si set<int>
#define usi set<int>
#define pb push_back
#define mp make_pair
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int arr[3];
		for(int i=0;i<3;i++){
			cin >> arr[i];
		}
		int a = arr[0] + arr[1];
		int b = arr[2];
		cout << floor(sqrt((b*b) + (a*a))) << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define si set<int>
#define usi set<int>
#define pb push_back
#define mp make_pair
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int arr[3];
		for(int i=0;i<3;i++){
			cin >> arr[i];
		}
		int a = arr[0] + arr[1];
		int b = arr[2];
		cout << sqrt((b*b) + (a*a)) << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define si set<int>
#define usi set<int>
#define pb push_back
#define mp make_pair
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int arr[3];
		for(int i=0;i<3;i++){
			cin >> arr[i];
		}
		sort(arr,arr+3);
		cout << arr[0] + arr[1] << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define si set<int>
#define usi set<int>
#define pb push_back
#define mp make_pair
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int arr[3];
		for(int i=0;i<3;i++){
			cin >> arr[i];
		}
		int a = arr[0] + arr[1];
		int b = arr[2];
		int ans = sqrt((b*b) + (a*a)));
		cout << ans << "\n";
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	long long a[5];
	cin>>t;
	while(t--){
		cin>>a[1]>>a[2]>>a[3];
		sort(a+1,a+4);
		//cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
		if(a[1]+a[2]>a[3]){
			cout<<"1"<<endl;
		}else{
			cout<<a[1]+a[2]+a[3]-1<<endl;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int T, a, b, c, n, m, k;
int main() {
	scanf("%d", &T);
	while(T--) {
		scanf("%d%d%d", &a, &b, &c);
        int n = max(max(a, b), c), m = min(min(a, b), c);
        if((n == a && m == b) || (n == b || m == a)) k = c;
        else if((n == c && m == b) || (n == b || m == c)) k = a;
        else k = b;
        for(int i = 1; ; i++)
            if(m + k > i && n - m < i) {
                printf("%d\n", i);
                break;
            }
	}
	return 0;
}


#include<iostream>

using namespace std;

int main(){

	long long n;

	for(long long i=1;i<=n;i++){

		long long ciN,Cin,cIn;

		cin>>ciN>>Cin>>cIn;

		cout<<(long long)(ciN+Cin+cIn-1) << endl;

	}

	return 0;

}


#include <cstdio>

using namespace std;

inline int max(int a,int b) { return a>b?a:b; }

int main()
{
	int n,a[4];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++) scanf("%d",&a[j]);
		a[3]=max(a[0],max(a[1],a[2]));
		printf("%d\n",a[3]);
	}
	return 0;


#include <iostream>
#include <cmath>
using namespace std;
int t;
int main(){
	cin >> t;
	while(t--){
	    long long a, b, c;
	    cin >> a >> b >> c;
		cout << a + b + c - 1;
	}
	return 0;
}


#include<stdio.h>
int main()
{
	int i,t,m,n,max,min,o,p;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&m,&n,&p);
		if(m>=n) {max=m; min=n;}
		else  {max=n; min=m;}
		if(max<p) {o=max; max=p;}
		else {if(p>min) o=p;
		else {o=min; min=p;}}
		printf("%d\n",max+min+o-1);
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main(){

	int n;

	for(int i=1;i<=n;i++){

		ll ciN,Cin,cIn;

		cin>>ciN>>Cin>>cIn;

		cout<<(ll)(ciN+Cin+cIn-1) << endl;

	}

	return 0;

}


#include<bits/stdc++.h>
using namespace std;
int T;
//目标 k个火把 也就是k个棍子+ k个煤炭
//操作1 一个棍子变x个棍子
//操作2 y个棍子变一个煤炭
//算一波总需要的棍子数量
//k*y + k
long long a,b,c;
int main() {
	scanf("%d",&T);

	while(T--) {
		scanf("%lld%lld%lld",&a,&b,&c);
		printf("%lld\n",a+b+c-1);
	}
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int T,a[3];
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        int ans = 1;
        scanf("%d %d %d",a,a + 1,a + 2);
        do
        {
            ans = max(ans, a[0] - a[1] - a[2] + 1);
        } while (next_permutation(a, a + 3));
        printf("%d\n",ans);
    }
    return 0;
}


#include <iostream>
using namespace std;
int main() {
    int times;
    cin >> times;
    while(times--){
        long long a,b,c;
        cin >> a >> b >> c;
        cout << max(max(a + b,b + c),a + c) - 1 << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main() {
    int times;
    cin >> times;
    while(times--){
        long long a,b,c;
        cin >> a >> b >> c;
        cout << (a + b + c - 1) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t = 1,n,a[3];
int main(){cin>>t;
while (t --){
	cin>>a[0]>>a[1]>>a[2],sort(a,a + 3),cout<<max(a[2] - a[1] - a[0],0LL) + 1<<endl;
}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n;
	for(int i=1;i<=n;i++){
		ll ciN,Cin,cIn;
		cin>>ciN>>Cin>>cIn;
		cout<<(ll)(ciN+Cin+cIn-1) << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	int n;
	cin>>n;
	while(n--){
		cin>>a>>b>>c
		cout<<a+b+c-1<<endl;
	}
	retunr 0;
}


#include<bits/stdc++.h>

using namespace std;

long long main(){

	ll n;

	for(long long i=1;i<=n;i++){

		long long ciN,Cin,cIn;

		cin>>ciN>>Cin>>cIn;

		cout<<(ciN+Cin+cIn-2) << endl;

	}

	return 0;

}


#include<bits/stdc++.h>
using namespace std;
int a;
int main(){
	cin>>a;
	for(int i=1;i<=a;i++){
		int x1,x2,y1,y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1==x2||y1==y2) cout<<abs(x1-x2)+abs(y1-y2)<<"\n";
		else cout<<abs(x1-x2)+abs(y1-y2)+2<<"\n";
	}
	return 0;
}


#include<stdio.h>
int main()
{
	int i,t,m,n,max,min,o,p;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&m,&n,&p);
		if(m>=n) {max=m; min=n;}
		else  {max=n; min=m;}
		if(max<p) {o=max;}
		else {if(p>min) o=p;
		       else o=min;}
		printf("%d\n",o);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long a=0,b=0,c=0;
int main()
{
	int n=0;
	cin>>n;
	for(int i=0;i<k;i++)
	{
		cin>>a>>b>>c;
		cout<<a+b+c-1;
	}
	return 0;
}


#include <iostream>
using namespace std;
int main() {
    int times;
    cin >> times;
    while(times--){
        int a,b,c;
        cin >> a >> b >> c;
        cout << (a + b + c - 1) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	for(int i=1;i<=n;i++){
		int ciN,Cin,cIn;
		cin>>ciN>>Cin>>cIn;
		cout<<(ciN+Cin+cIn-1);
	}
	return 0;
}


#include<stdio.h>
int main()
{
	int i,t,m,n,max,min,o,p;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&m,&n,&p);
		if(m>=n) {max=m; min=n;}
		else  {max=n; min=m;}
		if(max<p) {o=max; max=p;}
		else {if(p>min) o=p;
		else {o=min; min=p;}}
		printf("%d\n",max-min-o+1);
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--) {
		ll a, b, c;
		cin >> a >> b >> c;

		ll ss = a * a + b * b + c * c;
		ll ans = sqrt(3 * ss - 1);
		ll ans2 = a + b + c - 1;
		cout << min(ans, ans2) << endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;

		ll ss = a * a + b * b + c * c;
		ll ans = sqrt(3 * ss);

		cout << ans << endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;

		cout << (a + b + c) - 1 << endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;

		ll ss = a * a + b * b + c * c;
		ll ans = sqrt(3 * ss - 1);

		cout << ans << endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;

		cout << (a + b + c) - 2 << endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;

		if (a >= c) {
			int a1 = a - c;
			int ans = sqrt(a1 * a1 + b * b);
			cout << ans << endl;
		} else {
			int a1 = c - a;
			int ans = sqrt(a1 * a1 + b * b);
			cout << ans << endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        int a,b,c;
        cin >> a >> b >> c;
        int r = max(a,max(b,c));
        int d = sqrt(8*r*r - a*a - b*b - c*c);
        cout << d << "\n";
    }
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int t,a,b,c,doi;
  cin>>t;
  for (int i=0;i<t;i++)
  {
      cin>>a>>b>>c;
      if(a>b)
      {
          doi=a;a=b;b=doi;
      }
      if(a>c)
      {
          doi=a;a=c;c=doi;
      }
      cout<<b+c-a<<endl;
  }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        int a,b,c;
        cin >> a >> b >> c;
        if(abs(a-b)==1 && abs(b-c)== 1) cout << max(a,max(b,c))+1 << "\n";
        else if(abs(a-c)== 1 && abs(c-b) == 1)  cout << max(a,max(b,c))+1 << "\n";
        else if(abs(b-a)==abs(a-c)) cout << max(a,max(b,c))+1 << "\n";
        else{
            int l = a+b+c - max(a,max(b,c));
            int ans = (l-max(a,max(b,c)))/2;
            cout << ans + min(l,max(a,max(b,c))) << "\n";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        int a,b,c;
        cin >> a >> b >> c;
        if(abs(a-b)==abs(b-c) || abs(a-c)==abs(c-b) || abs(b-a)== abs(a-c)) cout << max(a,max(b,c))+1 << "\n";
        else{
            int res = a+b+c - max(a,max(b,c));
            int ans = rand()%(abs(res-max(a,max(b,c))+1)) + min(res,max(a,max(b,c)));
            cout << ans << "\n";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        int a,b,c;
        cin >> a >> b >> c;
        if(abs(a-b) == 1 && abs(b-c) == 1) cout << max(a,max(b,c))+1 << "\n";
        else if(abs(a-c) == 1 && abs(c-b) == 1)  cout << max(a,max(b,c))+1 << "\n";
        else if(abs(b-a) == 1 && abs(a-c) == 1) cout << max(a,max(b,c))+1 << "\n";
        else{
            int l = a+b+c - max(a,max(b,c));
            int ans = abs(l-max(a,max(b,c)))/2;
            cout << ans + min(l,max(a,max(b,c))) << "\n";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        int a,b,c;
        cin >> a >> b >> c;
        if(abs(a-b)==abs(b-c) || abs(a-c)==abs(c-b) || abs(b-a)==abs(a-c)) cout << max(a,max(b,c))+1 << "\n";
        else{
            int l = a+b+c - max(a,max(b,c));
            int ans = (l-max(a,max(b,c)))/2;
            cout << ans + min(l,max(a,max(b,c))) << "\n";
        }
    }
    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    long long a[5];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
        sort(a,a+3);
        printf("%lld\n",a[0]+a[1]+1);
    }
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    long long a[5];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
        sort(a,a+3);
        printf("%lld\n",a[0]+a[1]-1);
    }
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int t;
    int a[5];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&a[0],&a[1],&a[2]);
        sort(a,a+3);
        printf("%d\n",a[0]+a[1]+1);
    }
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int t,ans;
    int a[5];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&a[0],&a[1],&a[2]);
        sort(a,a+3);
        ans=a[2]-a[1]-a[0]+1;
        if(ans<=0)
            printf("1\n");
        else
            printf("0\n");
    }
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int t,ans;
    int a[5];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&a[0],&a[1],&a[2]);
        sort(a,a+3);
        ans=a[2]-a[1]-a[0]+1;
        if(ans<=0)
            printf("1\n");
        else
            printf("%d\n",ans);
    }
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		int a,b,c;
		cin>>a>>b>>c;
		int t=a+b+c;
		cout<<t-1<<"\n";

	}
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		vector<int> v(3);
		cin>>v[0]>>v[1]>>v[2];
		sort(v.begin(),v.end());
		cout<<v[0]+v[1]+1<<endl;

	}
}


#include <bits/stdc++.h>
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		long long a,b,c;
		cin>>a>>b>>c;
		long long z=(a+b+c-1);
		cout<<z<<endl;

	}
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		ll a,b,c;
		cin>>a>>b>>c;
		cout<<ll(a+b+c-1)<<endl;

	}
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		vector<int> v(3);
		cin>>v[0]>>v[1]>>v[2];
		sort(v.begin(),v.end());
		int z=v[3]-v[1];
		int x=(ceil)(sqrt((v[0]*v[0])+(z*z)));
		cout<<x<<endl;

	}
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		int a,b,c;
		cin>>a>>b>>c;
		int t=a+b+c;
		t/=3;
		cout<<t<<endl;

	}
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		int a,b,c;
		cin>>a>>b>>c;
		int t=a+b+c;
		t/=3;
		t+=min(a,min(b,c));
		cout<<t<<endl;

	}
}


#include <iostream>
using namespace std;
int main() {
    int T;
    long long a, b, c;
    cin >> T;
	while(T--) {
		cin >> a >> b >> c;
        cout << a + b + c - 1 << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pre(i,a,b) for(int i=a;i>=b;i--)
#define N 100005
using namespace std;
void solve(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	printf("%lld\n",(long long)a+b+c-1);
}
int main(){
	int T;scanf("%d",&T);
	while(T--)solve();
	return 0;
}


#include<stdio.h>
int main()
{
	int i,t,m,n,max,min,o,p;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&m,&n,&p);
		if(m>=n) {max=m; min=n;}
		else  {max=n; min=m;}
		if(max<p) {o=max; max=p;}
		else {if(p>min) o=p;
		else {o=min; min=p;}}
		printf("%d\n",max-min-o+1);
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

ll a[5];

int main(){
	ios::sync_with_stdio(false);
	int t;
	cin>>t;
	while(t--){
		for(int i=0;i<3;i++){
			cin>>a[i];
		}
		sort(a,a+3);
		if(a[0]+a[1]>a[2])	cout<<1<<endl;
		else cout<<a[0]+a[1]+a[2]-1<<endl;
	}

	return 0;
}


#include<stdio.h>
int main()
{
	int i,t,m,n,max,min,o,p;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d",&m,&n,&p);
		if(m>=n) {max=m; min=n;}
		else  {max=n; min=m;}
		if(max<p) {o=max; max=p;}
		else {if(p>min) o=p;
		else {o=min; min=p;}}
		if(t!=0)printf("%d\n",max-min-o+1);
		else printf("%d",max-min-o+1);
	}
	return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int t;
int main(){
	cin >> t;
	while(t--){
	    long long a, b, c;
	    cin >> a >> b >> c;
		cout << a + b + c - 1;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n;
	for(int i=1;i<=n;i++){
		ll ciN,Cin,cIn;
		cin>>ciN>>Cin>>cIn;
		cout<<(ciN+Cin+cIn-1) << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int T, a, b, c, n, m, k;
int main() {
	scanf("%d", &T);
	while(T--) {
		scanf("%d%d%d", &a, &b, &c);
        printf("%d\n", a + b + c + 1);
	}
	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int t;
	long long a,b,c;
	cin>>t;
	while(t--){
		cin>>a>>b>>c;
		cout<<a+b+c-1;
		if(t) cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[3];cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if(a[0]+a[1]>a[2]) cout<<1<<endl;
		else
		cout<<a[0]+a[2]+a[1]-1<<endl;
	}
}


#include<iostream>
using namespace std;
int main(){int a,b,c,t;for(cin>>t;t--;cin>>a>>b>>c,cout<<a+b+c-1<<endl);}


#include<iostream>
using namespace std;

int main(){
	int t;
	long long a,b,c;
	cin>>t;
	while(t--){
		cin>>a>>b>>c;
		cout<<a+b+c-1;
		if(t) cout<<endl;
	}
	return 0;
}
/*
min_d=2*max(a,b,c)-a-b-c+1
max_d=a+b+c-1
*/


#include<cstdio>
#include<iostream>
using namespace std;
int x;
long long x1,y1,z1;
int main(){
	cin>>x;
	for(int i=1;i<=x;i++) {
	cin>>x1>>y1>>z1;
	y1--;
	z1--;
	cout<<x1+y1+z1;
	}
	return 0;
}


#include<cstdio>

using namespace std;

int t;

int main(){
	scanf("%d", &t);

	while(t--){
		int a, b, c;

		scanf("%d%d%d", &a, &b, &c);

		printf("%d\n", a + b + c - 1);
	}

	return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		int m=abs(a-b);
		m=abs(m+c);
		cout<<m-1;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	int n;
	cin>>n;
	while(n--){
		cin>>a>>b>>c
		cout<<a+b+c-1<<endl;
	}
	retunr 0;
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	long long a[5];
	cin>>t;
	while(t--){
		cin>>a[1]>>a[2]>>a[3];
		sort(a+1,a+4);
		//cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
		if(a[1]+a[2]>a[3]){
			cout<<"1"<<endl;
		}else{
			cout<<a[1]+a[2]+a[3]-1<<endl;
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main(){

	int n;

	for(int i=1;i<=n;i++){

		ll ciN,Cin,cIn;

		cin>>ciN>>Cin>>cIn;

		cout<<(ciN+Cin+cIn-2) << endl;

	}

	return 0;

}


#include<iostream>

using namespace std;

long long main(){

	long long n;

	for(long long i=1;i<=n;i++){

		long long ciN,Cin,cIn;

		cin>>ciN>>Cin>>cIn;

		cout<<(long long)(ciN+Cin+cIn-1) << endl;

	}

	return 0;

}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll ans=c+a-b;
    	cout<<ans<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	int a,b,c;
    	cin>>a>>b>>c;

    	cout<<(c+a-b)<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll ans=a+b+c-1;
    	cout<<ans<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll ans=a+b-c;
    	cout<<ans<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll ans= a+b+c-1;
    	cout<<ans<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll ans=c+a+b;
    	cout<<ans<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	int t;
	cin>>t;
    while(t--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	ll ans=(a+b+c)/3;
    	cout<<ans<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long  a,b,c,n;
    cin>>n;
    while(n--){
    cin>>a>>b>>c;
    cout<<ceil(sqrt((c-a)*(c-a) + b*b)) + 1<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){

    long long  a,b,c,n;
    cin>>n;
    while(n--){
    cin>>a>>b>>c;
    cout<<a+b+c- 1<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long  a,b,c,n;
    cin>>n;
    while(n--){
    cin>>a>>b>>c;
    cout<<ceil(sqrt((c-a)*(c-a) + b*b)) + 1<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
  //  freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long  a,b,c,n;
    cin>>n;
    while(n--){
    cin>>a>>b>>c;
    cout<<a+b+c+ 1<<"\n";
	}
	return 0;
}


//#include <bits/stdc++.h>
//#define INF 1000000007
//#define EPS 1e-9
//#define in cin.sync_with_stdio(0);cin.tie(0);
//#define PI 3.14159265358979323846
//#define clr(v,d) memset(v,d,sizeof(v))
//#define all(v) v.begin(),v.end()
//#define sz(v) (int)v.size()
//#define mp make_pair
//#define pb push_back
//#define a first
//#define b second
//
//using namespace std;
//
//typedef long long ll;
//typedef pair<int,int> ii;
//
//ll n, x, y, mem[50004];
//vector<pair<ll, ll> > rec;
//
//int dp(int ind){
//  if(ind == n) return 0;
//  ll &r = mem[ind];
//  if(r != -1) return r;
//  r = INT_MAX;
//  for(int i=ind; i<n; i++){
//    r = min(r, dp(i+1)+(rec[i].a*rec[ind].b));
//  }
//  return r;
//}
//
//int main ()
//{
//
//  in;
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
//
//  clr(mem, -1);
//  cin >> n;
//  for(int i=0; i<n; i++){
//    cin >> x >> y;
//    rec.pb(mp(x, y));
//  }
//  sort(all(rec));
//  auto it = rec.end()-1;
//  while(it>rec.begin()){
//    if((*(it-1)).b<=(*it).b) rec.erase(it-1);
//    else it--;
//  }
//  for(auto A: rec) cout << A.a << " " << A.b << endl;
//
//
//  return 0;
//}
#include <bits/stdc++.h>
#define INF 1000000007
#define EPS 1e-9
#define in cin.sync_with_stdio(0);cin.tie(0);
#define PI 3.14159265358979323846
#define clr(v,d) memset(v,d,sizeof(v))
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int n, k, arr[100005], mxr;
vector<ii> R;

int main ()
{

//  in;
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

  cin >> n >> k;
  for(int i=0; i<n; ++i)
    cin >> arr[i];
  int l = 0, r = 0;
  while(l<n){
    while(r<n){
      if(abs(arr[l]-arr[r+1])<=k) r++;
      else break;
    }
    mxr = max(mxr, r-l+1);
    l++;
  }
//  cout << l << " " << r << endl;
  for(int i=0; i+mxr-1<n; i++){
    if(abs(arr[i]-arr[i+mxr-1])<=k) R.pb(mp(i+1, i+mxr));
  }
  cout << mxr << " " << sz(R) << endl;
  for(auto A: R)
    cout << A.F << " " << A.S << endl;

  return 0;
}


#include <bits/stdc++.h>
#define INF 1000000007
#define EPS 1e-9
#define in cin.sync_with_stdio(0);cin.tie(0);
#define PI 3.14159265358979323846
#define clr(v,d) memset(v,d,sizeof(v))
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int n, k, arr[100005], mxr;
vector<ii> R;

bool valid(int l, int r){
  int mxe = 0, mne = INT_MAX;
  for(int i=l; i<=r; i++){
    mxe = max(mxe, arr[i]);
    mne = min(mne, arr[i]);
  }
  return mxe-mne<=k;
}

int main ()
{

//  in;
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

  cin >> n >> k;
  for(int i=0; i<n; ++i)
    cin >> arr[i];
  int l = 0, r = 0;
  while(l<n){
    while(r<n-1){
      if(valid(l, r+1)) r++;
      else break;
    }
    mxr = max(mxr, r-l+1);
    l++;
  }
//  cout << l << " " << r << endl;
  for(int i=0; i+mxr-1<n; i++){
    if(valid(i, i+mxr-1)) R.pb(mp(i+1, i+mxr));
  }
  cout << mxr << " " << sz(R) << endl;
  for(auto A: R)
    cout << A.F << " " << A.S << endl;

  return 0;
}


//#include <bits/stdc++.h>
//#define INF 1000000007
//#define EPS 1e-9
//#define in cin.sync_with_stdio(0);cin.tie(0);
//#define PI 3.14159265358979323846
//#define clr(v,d) memset(v,d,sizeof(v))
//#define all(v) v.begin(),v.end()
//#define sz(v) (int)v.size()
//#define mp make_pair
//#define pb push_back
//#define a first
//#define b second
//
//using namespace std;
//
//typedef long long ll;
//typedef pair<int,int> ii;
//
//ll n, x, y, mem[50004];
//vector<pair<ll, ll> > rec;
//
//int dp(int ind){
//  if(ind == n) return 0;
//  ll &r = mem[ind];
//  if(r != -1) return r;
//  r = INT_MAX;
//  for(int i=ind; i<n; i++){
//    r = min(r, dp(i+1)+(rec[i].a*rec[ind].b));
//  }
//  return r;
//}
//
//int main ()
//{
//
//  in;
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
//
//  clr(mem, -1);
//  cin >> n;
//  for(int i=0; i<n; i++){
//    cin >> x >> y;
//    rec.pb(mp(x, y));
//  }
//  sort(all(rec));
//  auto it = rec.end()-1;
//  while(it>rec.begin()){
//    if((*(it-1)).b<=(*it).b) rec.erase(it-1);
//    else it--;
//  }
//  for(auto A: rec) cout << A.a << " " << A.b << endl;
//
//
//  return 0;
//}
#include <bits/stdc++.h>
#define INF 1000000007
#define EPS 1e-9
#define in cin.sync_with_stdio(0);cin.tie(0);
#define PI 3.14159265358979323846
#define clr(v,d) memset(v,d,sizeof(v))
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int n, k, arr[100005], mxr, mxe, mne = INT_MAX;
set<ii> R;

bool valid(int cur){
  return max(mxe, arr[cur])-min(mne, arr[cur]) <= k;
}

int main ()
{

  in;
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

  cin >> n >> k;
  for(int i=0; i<n; ++i)
    cin >> arr[i];
  int l = 0, r = -1;
  mne = mxe = arr[0];
  while(l<n){
    while(r<n-1){
      if(valid(r+1)){
        r++;
        mxe = max(mxe, arr[r]);
        mne = min(mne, arr[r]);
        if(r-l+1>mxr){
          R.clear();
          mxr = r-l+1;
          R.insert(mp(l+1, r+1));
        }
        if(r-l+1==mxr){
          R.insert(mp(l+1, r+1));
        }
      }
      else break;
    }
    mxr = max(mxr, r-l+1);
    l++;
    if(arr[l-1]==mxe){
      mxe = 0;
      for(int i=l; i<=r; i++) mxe = max(mxe, arr[i]);
    }
    if(arr[l-1]==mne){
      mne = INT_MAX;
      for(int i=l; i<=r; i++) mne = min(mne, arr[i]);
    }
  }
  cout << mxr << " " << sz(R) << endl;
  for(auto A: R)
    cout << A.F << " " << A.S << endl;

  return 0;
}


#include <bits/stdc++.h>
#define INF 1000000007
#define EPS 1e-9
#define in cin.sync_with_stdio(0);cin.tie(0);
#define PI 3.14159265358979323846
#define clr(v,d) memset(v,d,sizeof(v))
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int n, k, arr[100005], mxr;
set<ii> R;

bool valid(int l, int r){
  int mxe = 0, mne = INT_MAX;
  for(int i=l; i<=r; i++){
    mxe = max(mxe, arr[i]);
    mne = min(mne, arr[i]);
  }
  return mxe-mne<=k;
}

int main ()
{

  in;
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

  cin >> n >> k;
  for(int i=0; i<n; ++i)
    cin >> arr[i];
  int l = 0, r = 0;
  while(l<n){
    while(r<n-1){
      if(valid(l, r+1)){
        r++;
        if(r-l+1>mxr){
          R.clear();
          mxr = r-l+1;
          R.insert(mp(l+1, r+1));
        }
        if(r-l+1==mxr){
          R.insert(mp(l+1, r+1));
        }
      }
      else break;
    }
    mxr = max(mxr, r-l+1);
    l++;
  }
//  cout << l << " " << r << endl;
//  for(int i=0; i+mxr-1<n; i++){
//    if(valid(i, i+mxr-1)) R.pb(mp(i+1, i+mxr));
//  }
  cout << mxr << " " << sz(R) << endl;
  for(auto A: R)
    cout << A.F << " " << A.S << endl;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

bool poss(lli val, lli h[],lli k,lli n){
	set<pair<lli,lli>> min;
	set<pair<lli,lli>,greater<pair<lli,lli>>> max;
	for(lli i=0;i<val;++i){
		min.insert({h[i],i});
		max.insert({h[i],i});
	}
	lli lowest = ((*min.begin())).first;
	lli highest = ((*max.begin())).first;
	if(highest-lowest<=k)
		return true;
	for(lli i=val;i<n;++i){
		min.erase({h[i-val],i-val});
		max.erase({h[i-val],i-val});
		min.insert({h[i],i});
		max.insert({h[i],i});
		lli lowest = (*min.begin()).first;
		lli highest = (*max.begin()).first;
		if(highest-lowest<=k)
			return true;
		}
	return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	lli n,k;
 	cin>>n>>k;
 	lli h[n];
 	for(lli i=0;i<n;++i)
 		cin>>h[i];
 	lli low=1;
 	lli high=n;
 	lli ans=-1;
 	while(low<=high){
 		lli mid=(low+high)/2;
 		if(poss(mid,h,k,n)){
 			low=mid+1;
 			ans=mid;
 		}
 		else{
 			high=mid-1;
 		}
 	}
 	vector<pair<lli,lli>> ranges;
 	set<pair<lli,lli>> min;
	set<pair<lli,lli>,greater<pair<lli,lli>>> max;
	for(lli i=0;i<ans;++i){
		min.insert({h[i],i});
		max.insert({h[i],i});
	}
	lli lowest = ((*min.begin())).first;
	lli highest = ((*max.begin())).first;
	//cout<<lowest<<" "<<highest<<endl;
	if(highest-lowest<=k)
		ranges.push_back({0,ans-1});
	for(lli i=ans;i<n;++i){
		min.erase({h[i-ans],i-ans});
		max.erase({h[i-ans],i-ans});
		min.insert({h[i],i});
		max.insert({h[i],i});
		lli lowest = ((*min.begin()).first);
		lli highest = ((*max.begin()).first);
		//cout<<i<<" "<<lowest<<" "<<highest<<endl;
		if(highest-lowest<=k)
			ranges.push_back({i-ans+1,i});
	}
	cout<<ans<<" "<<ranges.size()<<endl;
	for(lli i=0;i<ranges.size();++i){
		cout<<ranges[i].first+1<<" "<<ranges[i].second+1<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

bool poss(lli val, lli h[],lli k,lli n){
	set<pair<lli,lli>> min;
	set<pair<lli,lli>,greater<pair<lli,lli>>> max;
	for(lli i=0;i<val;++i){
		min.insert({h[i],i});
		max.insert({h[i],i});
	}
	lli lowest = ((*min.begin())).first;
	lli highest = ((*max.begin())).first;
	if(highest-lowest<=k)
		return true;
	for(lli i=1;i<n-val+1;++i){
		min.erase({h[i-1],i-1});
		max.erase({h[i-1],i-1});
		min.insert({h[i],i});
		max.insert({h[i],i});
		lli lowest = (*min.begin()).first;
		lli highest = (*max.begin()).first;
		if(highest-lowest<=k)
			return true;
		}
	return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	lli n,k;
 	cin>>n>>k;
 	lli h[n];
 	for(lli i=0;i<n;++i)
 		cin>>h[i];
 	lli low=1;
 	lli high=n;
 	lli ans=-1;
 	while(low<=high){
 		lli mid=(low+high)/2;
 		if(poss(mid,h,k,n)){
 			low=mid+1;
 			ans=mid;
 		}
 		else{
 			high=mid-1;
 		}
 	}
 	vector<pair<lli,lli>> ranges;
 	set<pair<lli,lli>> min;
	set<pair<lli,lli>,greater<pair<lli,lli>>> max;
	for(lli i=0;i<ans;++i){
		min.insert({h[i],i});
		max.insert({h[i],i});
	}
	lli lowest = ((*min.begin())).first;
	lli highest = ((*max.begin())).first;
	//cout<<lowest<<" "<<highest<<endl;
	if(highest-lowest<=k)
		ranges.push_back({0,ans-1});
	for(lli i=ans;i<n;++i){
		min.erase({h[i-ans],i-ans});
		max.erase({h[i-ans],i-ans});
		min.insert({h[i],i});
		max.insert({h[i],i});
		lli lowest = ((*min.begin()).first);
		lli highest = ((*max.begin()).first);
		//cout<<i<<" "<<lowest<<" "<<highest<<endl;
		if(highest-lowest<=k)
			ranges.push_back({i-ans+1,i});
	}
	cout<<ans<<" "<<ranges.size()<<endl;
	for(lli i=0;i<ranges.size();++i){
		cout<<ranges[i].first+1<<" "<<ranges[i].second+1<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

}


#include<bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<=k;i++)
#define int long long
#define oo 10e9
#define N 500500
#define pii pair<int,int>
#define mp make_pair
using namespace std;
int n , k;
int h[N] , mn[N] , mx[N] , out[N];

void build(int v, int l , int r){
    if(l == r) mn[v] = mx[v] = h[l];
    else{
        int mid = (l+r) / 2;
        build(v*2,l, mid);
        build(v*2+1,mid+1,r);
        mn[v] = min(mn[2*v],mn[2*v+1]);
        mx[v] = max(mx[2*v],mx[2*v+1]);
    }
}

pii get(int v,int l, int r,int le,int ri){
    if( l>=le && r<=ri ){
    	pii g = mp(mx[v],mn[v]);
	 	return g;
	}
    int mid=(l+r) / 2;
    pii g , h , res ;
    h = g = make_pair(-oo,oo);
    if(mid >= le) h = get(v*2,l,mid,le,ri);
    if(mid < ri) g = get(v*2+1,mid+1,r,le,ri);
    res.first = max(h.first,g.first) ;
    res.second = min(h.second,g.second);
    return res;
}

main(){
	int ans = 0, res;
	cin>>n>>k;
	f(x,1,n) cin>>h[x];
	build(1,1,n);
	pii tg = get(1,1,n,1,3);
	f(x,1,n){
		res = 0;
		int l = x , r = n , st = x;
		while(l<=r){
			int mid = (l+r)/2;
			pii tg = get(1,1,n,st,mid);
			if( ( tg.first - tg.second ) <= k ) res = max(res , mid-st+1) , l = mid + 1 ;
			else r = mid - 1;
		}
		ans = max(ans,res);
		out[x] = res;
	}
	int d = 0;
	f(x,1,n) if(out[x] == ans) d++;
	cout<<ans<<" "<<d<<endl;
	f(x,1,n)
		if(ans==1) cout<<x<<" "<<x<<endl;
		else if(out[x] == ans){
			f(y,x,x+ans-1) cout<<y<<" ";
			cout<<endl;
		}
}


#include<bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<=k;i++)
#define int long long
#define oo 10e9
#define N 500500
#define pii pair<int,int>
#define mp make_pair
using namespace std;
int n , k;
int h[N] , mn[N] , mx[N] , out[N];

void build(int v, int l , int r){
    if(l == r) mn[v] = mx[v] = h[l];
    else{
        int mid = (l+r) / 2;
        build(v*2,l, mid);
        build(v*2+1,mid+1,r);
        mn[v] = min(mn[2*v],mn[2*v+1]);
        mx[v] = max(mx[2*v],mx[2*v+1]);
    }
}

pii get(int v,int l, int r,int le,int ri){
    if( l>=le && r<=ri ){
    	pii g = mp(mx[v],mn[v]);
	 	return g;
	}
    int mid=(l+r) / 2;
    pii g , h , res ;
    h = g = make_pair(-oo,oo);
    if(mid >= le) h = get(v*2,l,mid,le,ri);
    if(mid < ri) g = get(v*2+1,mid+1,r,le,ri);
    res.first = max(h.first,g.first) ;
    res.second = min(h.second,g.second);
    return res;
}

main(){
	int ans = 0, res;
	cin>>n>>k;
	f(x,1,n) cin>>h[x];
	build(1,1,n);
	pii tg = get(1,1,n,1,3);
	f(x,1,n){
		res = 0;
		int l = x , r = n , st = x;
		while(l<=r){
			int mid = (l+r)/2;
			pii tg = get(1,1,n,st,mid);
			if( ( tg.first - tg.second ) <= k ) res = max(res , mid-st+1) , l = mid + 1 ;
			else r = mid - 1;
		}
		ans = max(ans,res);
		out[x] = res;
	}
	int d = 0;
	f(x,1,n) if(out[x] == ans) d++;
	cout<<ans<<" "<<d<<endl;
	f(x,1,n)
		if(out[x]==ans)
			cout<<x<<" "<<x+ans-1<<endl;
}


#include<bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<=k;i++)
#define int long long
#define oo 10e9
#define N 500500
#define pii pair<int,int>
#define mp make_pair
using namespace std;
int n , k;
int h[N] , mn[N] , mx[N] , out[N];

void build(int v, int l , int r){
    if(l == r) mn[v] = mx[v] = h[l];
    else{
        int mid = (l+r) / 2;
        build(v*2,l, mid);
        build(v*2+1,mid+1,r);
        mn[v] = min(mn[2*v],mn[2*v+1]);
        mx[v] = max(mx[2*v],mx[2*v+1]);
    }
}

pii get(int v,int l, int r,int le,int ri){
    if( l>=le && r<=ri ){
    	pii g = mp(mx[v],mn[v]);
	 	return g;
	}
    int mid=(l+r) / 2;
    pii g , h , res ;
    h = g = make_pair(-oo,oo);
    if(mid >= le) h = get(v*2,l,mid,le,ri);
    if(mid < ri) g = get(v*2+1,mid+1,r,le,ri);
    res.first = max(h.first,g.first) ;
    res.second = min(h.second,g.second);
    return res;
}

main(){
	int ans = 0, res;
	cin>>n>>k;
	f(x,1,n) cin>>h[x];
	build(1,1,n);
	pii tg = get(1,1,n,1,3);
	f(x,1,n){
		res = 0;
		int l = x , r = n , st = x;
		while(l<=r){
			int mid = (l+r)/2;
			pii tg = get(1,1,n,st,mid);
			if( ( tg.first - tg.second ) <= k ) res = max(res , mid-st+1) , l = mid + 1 ;
			else r = mid - 1;
		}
		ans = max(ans,res);
		out[x] = res;
	}
	int d = 0;
	f(x,1,n) if(out[x] == ans) d++;
	cout<<ans<<" "<<d<<endl;
	f(x,1,n)
		if(out[x] == ans){
			f(y,x,x+ans-1) cout<<y<<" ";
			cout<<endl;
		}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N=100011;

ll A[N];
ll spt1[N][20];
ll spt2[N][20];

void build1(ll n){
	for(ll i=0; i<n; i++){
		spt1[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt1[i][j]=min(spt1[i][j-1],spt1[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query1(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return min(spt1[l][j],spt1[r-(1<<j)+1][j]);
}

void build2(ll n){
	for(ll i=0; i<n; i++){
		spt2[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt2[i][j]=max(spt2[i][j-1],spt2[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query2(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return max(spt2[l][j],spt2[r-(1<<j)+1][j]);
}

int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=0; i<n; i++){
		cin>>A[i];
	}
	build1(n);
	build2(n);
	ll pos=0;
	ll mx=-1;
	vector< pair<ll,ll> > v;
	for(ll i=0; i<n; i++){
		ll aux=query2(pos,i)-query1(pos,i);
		if(aux>k){
			while(true){
				pos++;
				aux=query2(pos,i)-query1(pos,i);
				if(aux<=k){
					break;
				}
			}
		}
		if(mx<i-pos+1){
			mx=i-pos+1;
			v.clear();
			v.push_back(make_pair(pos,i));
		}else if(mx==i-pos+1){
			v.push_back(make_pair(pos,i));
		}
	}
	cout<<mx<<" "<<ll(v.size())<<endl;
	for(ll i=0; i<ll(v.size()); i++){
		cout<<v[i].first+1<<" "<<v[i].second+1<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N=100001;

ll A[N];
ll spt1[N][20];
ll spt2[N][20];

void build1(ll n){
	for(ll i=0; i<n; i++){
		spt1[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt1[i][j]=min(spt1[i][j-1],spt1[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query1(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return min(spt1[l][j],spt1[r-(1<<j)+1][j]);
}

void build2(ll n){
	for(ll i=0; i<n; i++){
		spt2[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt2[i][j]=max(spt2[i][j-1],spt2[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query2(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return max(spt2[l][j],spt2[r-(1<<j)+1][j]);
}

int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=0; i<n; i++){
		cin>>A[i];
	}
	build1(n);
	build2(n);
	ll pos=0;
	ll mx=-1;
	vector< pair<ll,ll> > v;
	for(ll i=0; i<n; i++){
		ll aux=query2(pos,i)-query1(pos,i);
		if(aux>k){
			while(true){
				pos++;
				aux=query2(pos,i)-query1(pos,i);
				if(aux<=k){
					break;
				}
			}
		}
		if(mx<i-pos+1){
			mx=i-pos+1;
			v.clear();
			v.push_back(make_pair(pos,i));
		}else if(mx==i-pos+1){
			v.push_back(make_pair(pos,i));
		}
	}
	cout<<mx<<" "<<ll(v.size())<<endl;
	for(ll i=0; i<ll(v.size()); i++){
		cout<<v[i].first+1<<" "<<v[i].second+1<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N=100001;

ll A[N];
ll spt1[N][20];
ll spt2[N][20];

void build1(ll n){
	for(ll i=0; i<n; i++){
		spt1[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt1[i][j]=min(spt1[i][j-1],spt1[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query1(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return min(spt1[l][j],spt1[r-(1<<j)+1][j]);
}

void build2(ll n){
	for(ll i=0; i<n; i++){
		spt2[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt2[i][j]=max(spt2[i][j-1],spt2[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query2(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return max(spt2[l][j],spt2[r-(1<<j)+1][j]);
}

int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=0; i<n; i++){
		cin>>A[i];
	}
	build1(n);
	build2(n);
	ll pos=0;
	ll mx=-1;
	vector< pair<ll,ll> > v;
	for(ll i=0; i<n; i++){
		ll aux=query2(i,pos)-query1(i,pos);
		if(aux>k){
			while(true){
				pos++;
				aux=query2(i,pos)-query1(i,pos);
				if(aux<=k){
					break;
				}
			}
		}
		if(mx<i-pos+1){
			mx=i-pos+1;
			v.clear();
			v.push_back(make_pair(pos,i));
		}else if(mx==i-pos+1){
			v.push_back(make_pair(pos,i));
		}
	}
	cout<<mx<<" "<<ll(v.size())<<endl;
	for(ll i=0; i<ll(v.size()); i++){
		cout<<v[i].first+1<<" "<<v[i].second+1<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N=100011;

//

ll A[N];
ll spt1[N][20];
ll spt2[N][20];

void build1(ll n){
	for(ll i=0; i<n; i++){
		spt1[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt1[i][j]=min(spt1[i][j-1],spt1[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query1(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return min(spt1[l][j],spt1[r-(1<<j)+1][j]);
}

void build2(ll n){
	for(ll i=0; i<n; i++){
		spt2[i][0]=A[i];
	}
	for(ll j=1; (1<<j)<=n; j++){
		for(ll i=0; (i+(1<<j)-1)<n; i++){
			spt2[i][j]=max(spt2[i][j-1],spt2[i+(1<<(j-1))][j-1]);
		}
	}
	return;
}

ll query2(ll l, ll r){
	ll j=ll(log2(r-l+1));
	return max(spt2[l][j],spt2[r-(1<<j)+1][j]);
}

int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=0; i<n; i++){
		cin>>A[i];
	}
	build1(n);
	build2(n);
	ll pos=0;
	ll mx=-1;
	vector< pair<ll,ll> > v;
	for(ll i=0; i<n; i++){
		ll aux=query2(pos,i)-query1(pos,i);
		if(aux>k){
			while(true){
				pos++;
				aux=query2(pos,i)-query1(pos,i);
				if(aux<=k){
					break;
				}
			}
		}
		if(mx<i-pos+1){
			mx=i-pos+1;
			v.clear();
			v.push_back(make_pair(pos,i));
		}else if(mx==i-pos+1){
			v.push_back(make_pair(pos,i));
		}
	}
	cout<<mx<<" "<<ll(v.size())<<endl;
	for(ll i=0; i<ll(v.size()); i++){
		cout<<v[i].first+1<<" "<<v[i].second+1<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define scn(a) scanf("%lld", &a)
#define INF 1000000007
#define mp make_pair
#define pb push_back

using namespace std;

int main() {
	LL n, k;
	scn(n);scn(k);

	LL h[n];
	for(LL i=0;i<n;i++)
		scn(h[i]);

	multiset<LL>s;
	map<LL, vector<pair<LL,LL>>>m;

	s.insert(h[0]);
	LL i=0,j=0,ans=0;
	while(i<=j && j<n) {
		// cout<<"i= "<<i<<" j= "<<j<<endl;
		if(s.size()<2)
			s.insert(h[++j]);

		auto x=s.begin();
		auto y=s.rbegin();

		LL d=*y-*x;
		// cout<<"d= "<<d<<endl;

		if(s.size()>ans && d<=k)ans=s.size();

		if(d<=k) {
			m[s.size()].pb(mp(i,j));
			j++;
			s.insert(h[j]);
		} else {
			s.erase(h[i]);
			i++;
		}
	}

	cout<<ans<<" "<<m[ans].size()<<endl;
	for(auto x:m[ans]) {
		cout<<x.first+1<<" "<<x.second+1<<endl;
	}
}


#include<bits/stdc++.h>

#define LL long long
#define scn(a) scanf("%lld", &a)
#define INF 1000000007
#define mp make_pair
#define pb push_back

using namespace std;

int main() {
	LL n, k;
	scn(n);scn(k);

	LL h[n];
	for(LL i=0;i<n;i++)
		scn(h[i]);

	multiset<LL>s;
	map<LL, vector<pair<LL,LL>>>m;

	s.insert(h[0]);
	LL i=0,j=0,ans=1;
	while(i<=j && j<n) {
		if(s.size()==1) {
			m[1].pb(mp(i, i));
		}

		// cout<<"i= "<<i<<" j= "<<j<<endl;
		if(s.size()<2)
			s.insert(h[++j]);

		auto x=s.begin();
		auto y=s.rbegin();

		// cout<<"min= "<<*x<<" max= "<<*y<<endl;

		LL d=*y-*x;
		// cout<<"d= "<<d<<endl;

		if(s.size()>ans && d<=k)ans=s.size();

		if(d<=k) {
			m[s.size()].pb(mp(i,j));
			j++;
			s.insert(h[j]);
		} else {
			s.erase(s.find(h[i]));
			i++;
		}
	}

	cout<<ans<<" "<<m[ans].size()<<endl;
	for(auto x:m[ans]) {
		cout<<x.first+1<<" "<<x.second+1<<endl;
	}
}


#include<bits/stdc++.h>

#define LL long long
#define scn(a) scanf("%lld", &a)
#define INF 1000000007
#define mp make_pair
#define pb push_back

using namespace std;

int main() {
	LL n, k;
	scn(n);scn(k);

	LL h[n];
	for(LL i=0;i<n;i++)
		scn(h[i]);

	multiset<LL>s;
	map<LL, vector<pair<LL,LL>>>m;

	s.insert(h[0]);
	LL i=0,j=0,ans=1;
	while(i<=j && j<n) {
		if(s.size()==1) {
			m[1].pb(mp(i, i));
		}

		// cout<<"i= "<<i<<" j= "<<j<<endl;
		if(s.size()<2)
			s.insert(h[++j]);

		auto x=s.begin();
		auto y=s.rbegin();

		LL d=*y-*x;
		// cout<<"d= "<<d<<endl;

		if(s.size()>ans && d<=k)ans=s.size();

		if(d<=k) {
			m[s.size()].pb(mp(i,j));
			j++;
			s.insert(h[j]);
		} else {
			s.erase(h[i]);
			i++;
		}
	}

	cout<<ans<<" "<<m[ans].size()<<endl;
	for(auto x:m[ans]) {
		cout<<x.first+1<<" "<<x.second+1<<endl;
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

int main()
{
long long int n,h,i;
cin>>n>>h;
if (n==1) {
    cout<<"1 1\n1 1"; return 0;
}
long long int arr[n]; // n = 1
long long int difur[n-1];

for (i=0; i<n; i++)
    {cin>>arr[i];
    if (i>0) difur[i-1]=arr[i]-arr[i-1];}

long long int maxi=1;
long long int lmaxi=0, lmini=0;
long long int cmax=0;

long long int sum=0;

long long int k=0;
long long int first=0, last=0;
long long int diffur=0;
vector <pair <long long int, long long int> > ans;
map <long long int, int> blessRNG;
map <long long int, int> :: iterator it;
//ans.push_back(pair <long long int, long long int> (1,1));
for (i=0; i<n; i++) {
      //  cout<<"first = "<<first<<"\n";

       if (lmaxi==0 && lmini ==0) {lmaxi=arr[i]; lmini=arr[i];}

       else {if (arr[i]>lmaxi) lmaxi=arr[i];
       if (arr[i]<lmini) lmini=arr[i];
       diffur=abs(lmaxi-lmini);
       }
       blessRNG[arr[i]]++;
//if (i==3) {cout<<"lmaxi = "<<lmaxi<<" lmini = "<<lmini<<" k "<<k<<"\n";}

    if (diffur<=h) {k++;

    if (k==maxi) {ans.push_back(pair <long long int, long long int>  (first+1, i+1));}
    if (k>maxi)
        {ans.clear(); maxi=k; ans.push_back(pair <long long int,long long  int> (first+1, i+1)); }
     }
     else {
        //k++;
        //cout<<" i = "<<i<<"first = "<<first<<" difur = "<<diffur<<"\n";
        while (true)
        {
        if (arr[first]==lmini)
            {
               // cout<<"JA";
            blessRNG[lmini]--;
            if (blessRNG[lmini]==0) blessRNG.erase(lmini);
            it=blessRNG.begin();
            //cout<<" It = "<<it->first<<"\n";
            lmini=it->first;
            }
        if (arr[first]==lmaxi)
            {
            blessRNG[lmaxi]--;
            if (blessRNG[lmaxi]==0) blessRNG.erase(lmaxi);
            it=blessRNG.end();
            it--;
            lmaxi=it->first;
            }
        first++;
        diffur=abs(lmaxi-lmini);

      //  cout<<" d = "<<diffur<<"\n";
        if (diffur<=h) break;
        if (first==i) break;
        k--;
        }
        if (first==i) {lmaxi=arr[i]; lmini=arr[i];}

        if (k==maxi) {ans.push_back(pair <long long int, long long int>  (first+1, i+1));}

        }
}
//if (maxi==1)
   // ans.push_back(pair <int, int> (1,1));
cout<<maxi<<" "<<ans.size()<<"\n";
for (i=0; i<ans.size(); i++)
    cout<<ans[i].first<<" "<<ans[i].second<<"\n";
return 0;

}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

int main()
{
int n,h,i;
cin>>n>>h;
if (n==1) {
    cout<<"1 1\n1 1"; return 0;
}
int arr[n]; // n = 1
int difur[n-1];

for (i=0; i<n; i++)
    {cin>>arr[i];
    if (i>0) difur[i-1]=arr[i]-arr[i-1];}

int maxi=1;
int lmaxi=0, lmini=0;
int cmax=0;

int sum=0;

int k=1;
int first=0, last=0;
vector <pair <int, int> > ans;
ans.push_back(pair <int, int> (1,1));
for (i=0; i<n-1; i++) {
       // if (first==0) first=i;

    sum+=difur[i];
   // cout<<"sum = "<<sum;
    if (abs(sum)<=h) {k++;
    if (k==maxi) {ans.push_back(pair <int, int>  (first+1, i+2));}
    if (k>maxi)
        {ans.clear(); maxi=k; ans.push_back(pair <int, int> (first+1, i+2)); }

     }
     else {
            k++;
        while (true)
        {
        sum-=difur[first];
        first++;
        //cout<<"sum = "<<sum<<"\n";
        k--;
    //    cout<<"while first = "<<first<<" ";
        if (abs(sum)<=h) break;
        if (first==i+1) break;
        }
       // cout<<"k = "<<k<<"\n\n";
        if (k==maxi) {ans.push_back(pair <int, int>  (first+1, i+2));}
        //cout<<"k = "<<k<<"\n";
     //i--;
        }
}
//if (maxi==1)
   // ans.push_back(pair <int, int> (1,1));
cout<<maxi<<" "<<ans.size()<<"\n";
for (i=0; i<ans.size(); i++)
    cout<<ans[i].first<<" "<<ans[i].second<<"\n";
return 0;

}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

int main()
{
long long int n,h,i;
cin>>n>>h;
if (n==1) {
    cout<<"1 1\n1 1"; return 0;
}
long long int arr[n]; // n = 1
long long int difur[n-1];

for (i=0; i<n; i++)
    {cin>>arr[i];
    if (i>0) difur[i-1]=arr[i]-arr[i-1];}

long long int maxi=1;
long long int lmaxi=0, lmini=0;
long long int cmax=0;

long long int sum=0;

long long int k=1;
long long int first=0, last=0;
vector <pair <long long int, long long int> > ans;
ans.push_back(pair <long long int, long long int> (1,1));
for (i=0; i<n-1; i++) {
       // if (first==0) first=i;

    sum+=difur[i];
   // cout<<"sum = "<<sum;
    if (abs(sum)<=h) {k++;
    if (k==maxi) {ans.push_back(pair <long long int, long long int>  (first+1, i+2));}
    if (k>maxi)
        {ans.clear(); maxi=k; ans.push_back(pair <long long int,long long  int> (first+1, i+2)); }

     }
     else {
            k++;
        while (true)
        {
        sum-=difur[first];
        first++;
        //cout<<"sum = "<<sum<<"\n";
        k--;
    //    cout<<"while first = "<<first<<" ";
        if (abs(sum)<=h) break;
        if (first==i+1) break;
        }
       // cout<<"k = "<<k<<"\n\n";
        if (k==maxi) {ans.push_back(pair <long long int, long long int>  (first+1, i+2));}
        //cout<<"k = "<<k<<"\n";
     //i--;
        }
}
//if (maxi==1)
   // ans.push_back(pair <int, int> (1,1));
cout<<maxi<<" "<<ans.size()<<"\n";
for (i=0; i<ans.size(); i++)
    cout<<ans[i].first<<" "<<ans[i].second<<"\n";
return 0;

}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

int main()
{
long long int n,h,i;
cin>>n>>h;
if (n==1) {
    cout<<"1 1\n1 1"; return 0;
}
long long int arr[n]; // n = 1
long long int difur[n-1];

for (i=0; i<n; i++)
    {cin>>arr[i];
    if (i>0) difur[i-1]=arr[i]-arr[i-1];}

long long int maxi=1;
long long int lmaxi=0, lmini=0;
long long int cmax=0;

long long int sum=0;

long long int k=0;
long long int first=0, last=0;
long long int diffur=0;
vector <pair <long long int, long long int> > ans;
map <long long int, int> blessRNG;
map <long long int, int> :: iterator it;
//ans.push_back(pair <long long int, long long int> (1,1));
for (i=0; i<n; i++) {
      //  cout<<"first = "<<first<<"\n";

       if (lmaxi==0 && lmini ==0) {lmaxi=arr[i]; lmini=arr[i];}

       else {if (arr[i]>lmaxi) lmaxi=arr[i];
       if (arr[i]<lmini) lmini=arr[i];
       diffur=abs(lmaxi-lmini);
       }
       blessRNG[arr[i]]++;
//if (i==3) {cout<<"lmaxi = "<<lmaxi<<" lmini = "<<lmini<<" k "<<k<<"\n";}

    if (diffur<=h) {k++;

    if (k==maxi) {ans.push_back(pair <long long int, long long int>  (first+1, i+1));}
    if (k>maxi)
        {ans.clear(); maxi=k; ans.push_back(pair <long long int,long long  int> (first+1, i+1)); }
     }
     else {
        //k++;
        //cout<<" i = "<<i<<"first = "<<first<<" difur = "<<diffur<<"\n";
        while (true)
        {
        if (arr[first]==lmini)
            {
               // cout<<"JA";
            blessRNG[lmini]--;
            if (blessRNG[lmini]==0) blessRNG.erase(lmini);
            it=blessRNG.begin();
            //cout<<" It = "<<it->first<<"\n";
            lmini=it->first;
            }
        if (arr[first]==lmaxi)
            {
            blessRNG[lmaxi]--;
            if (blessRNG[lmaxi]==0) blessRNG.erase(lmaxi);
            it=blessRNG.end();
            it--;
            lmaxi=it->first;
            }
        first++;
        diffur=abs(lmaxi-lmini);

      //  cout<<" d = "<<diffur<<"\n";
        if (diffur<=h) break;
        if (first==i) break;
        k--;
        }

        if (k==maxi) {ans.push_back(pair <long long int, long long int>  (first+1, i+1));}

        }
}
//if (maxi==1)
   // ans.push_back(pair <int, int> (1,1));
cout<<maxi<<" "<<ans.size()<<"\n";
for (i=0; i<ans.size(); i++)
    cout<<ans[i].first<<" "<<ans[i].second<<"\n";
return 0;

}


#include <bits/stdc++.h>
#include <float.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ppi pair<int,pi >
#define ppl pair<ll,pl >
#define ld long double
#define pb push_back
#define F first
#define S second
#define int long long
int mod=1e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   #endif
   int n,k;cin>>n>>k;
   int f[(int)1e6+1]={0};
   int l=0;
   int r=0;
   int dp[n];
   set<int> s;
   set<int> d;
   int h[n];
   for(int i=0;i<n;i++)
   {
     cin>>h[i];
   }
   int ans=0;
   map<int,int> m;
   for(int i=0;i<n;i++)
   {
    if(r<i) r=i;
    s.insert(h[i]);
    d.insert(-h[i]);
    f[h[i]]++;
    int a=*( s.begin() );
    int b=-*( d.begin() );
    while(r<n)
    {
      a=min(a,h[r]);
      b=max(b,h[r]);
      if(b-a<=k)
      {
        s.insert(h[r]);
        d.insert(-h[r]);
        r++;
        continue;
      }
      break;
    }
    dp[i]=r-i;
    m[dp[i]]++;
    ans=max(ans,dp[i]);
    f[h[i]]--;
    if( f[h[i]]==0 )
    {
      s.erase( s.find(h[i]) );
      d.erase( d.find(-h[i] ) );
    }
   }
   cout<<ans<<" "<<m[ans]<<endl;
   for (int i = 0; i < n; ++i)
   {
     if(dp[i]!=ans) continue;
     cout<<i+1<<" "<<dp[i]+i<<endl;
   }
   return 0;
}


#include <bits/stdc++.h>
#include <float.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ppi pair<int,pi >
#define ppl pair<ll,pl >
#define ld long double
#define pb push_back
#define F first
#define S second
#define int long long
int mod=1e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   #endif
   int n,k;cin>>n>>k;
   int f[(int)1e6+1]={0};
   int l=0;
   int r=0;
   int dp[n];
   set<int> s;
   set<int> d;
   int h[n];
   for(int i=0;i<n;i++)
   {
     cin>>h[i];
   }
   int ans=0;
   map<int,int> m;
   for(int i=0;i<n;i++)
   {
    if(r<=i)
    {
      r=i+1;
      s.insert( h[i] );
      d.insert( -h[i] );
      f[h[i]]++;
    }
    int a=*(s.begin());
    int b=-*(d.begin() );
    while(r<n)
    {
      a=min(a,h[r]);
      b=max(b,h[r]);
      if(b-a<=k)
      {
        s.insert(h[r]);
        d.insert(-h[r]);
        f[h[r]]++;
        r++;
        continue;
      }
      break;
    }
    dp[i]=r-i;
    m[dp[i]]++;
    ans=max(ans,dp[i]);
    f[h[i]]--;
    if( f[h[i]]==0 )
    {
      s.erase( s.find(h[i]) );
      d.erase( d.find(-h[i] ) );
    }
   }
   cout<<ans<<" "<<m[ans]<<endl;
   for (int i = 0; i < n; ++i)
   {
     if(dp[i]!=ans) continue;
     cout<<i+1<<" "<<dp[i]+i<<endl;
   }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define PI acos(-1)
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define endl "\n"
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
#define bug(n) {outl(n);return;}
#define N 100005
ll n,k,a[N];
pll tree[4*N];
map<ll,vpll> ans;
pll combine(pll a, pll b){
    if(a.fi==hell)return b;
    if(b.fi==hell)return a;
    return {min(a.fi,b.fi),max(a.se,b.se)};
}
void build(ll cur, ll l, ll r){
    if(l==r){
        tree[cur]={a[l],a[l]};
        return;
    }
    ll mid=(l+r)/2;
    build(2*cur,l,mid);
    build(2*cur+1,mid+1,r);
    tree[cur]=combine(tree[2*cur],tree[2*cur+1]);
}
pll query(ll cur, ll l, ll r, ll x, ll y){
    if(l>r||y<l||x>r)
        return {hell,0};
    if(x<=l&&r<=y)
        return tree[cur];
    ll mid=(l+r)/2;
    return combine(query(2*cur,l,mid,x,y),query(2*cur+1,mid+1,r,x,y));
}
bool check(ll l, ll r){
    pll ans=query(1,1,n,l,r);
    return ans.se-ans.fi<=k;
}
void solve(){
    cin>>n>>k;
    rep(i,1,n+1)cin>>a[i];
    build(1,1,n);
    rep(i,1,n+1){
        ll l=i,r=n,mid;
        while(r-l>1){
            mid=(l+r)/2;
            if(check(i,mid))l=mid;
            else r=mid;
        }
        if(check(i,r))ans[r-i+1].pb({i,r});
        else ans[l-i+1].pb({i,l});
    }
    auto it=ans.end();
    it--;
    outl(it->fi<<" "<<sz(it->se));
    for(auto i:it->se)outl(i.fi<<" "<<i.se);
}
void prep(){

}
int main(){
    io;
    ll t=1;
    // cin>>t;
    prep();
    fix(12);
    while(t--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define PI acos(-1)
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define endl "\n"
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
#define bug(n) {outl(n);return;}
#define N 100005
ll n,k,a[N];
pll tree[4*N];
map<ll,vpll> ans;
pll combine(pll a, pll b){
    if(a.fi==hell)return b;
    if(b.fi==hell)return a;
    return {min(a.fi,b.fi),max(a.se,b.se)};
}
void build(ll cur, ll l, ll r){
    if(l==r){
        tree[cur]={a[l],a[l]};
        return;
    }
    ll mid=(l+r)/2;
    build(2*cur,l,mid);
    build(2*cur+1,mid+1,r);
    tree[cur]=combine(tree[2*cur],tree[2*cur+1]);
}
pll query(ll cur, ll l, ll r, ll x, ll y){
    if(l>r||y<l||x>r)
        return {hell,0};
    if(x<=l&&r<=y)
        return tree[cur];
    ll mid=(l+r)/2;
    return combine(query(2*cur,l,mid,x,y),query(2*cur+1,mid+1,r,x,y));
}
bool check(ll l, ll r){
    pll ans=query(1,1,n,l,r);
    return ans.se-ans.fi<=k;
}
void solve(){
    cin>>n>>k;
    rep(i,1,n+1)cin>>a[i];
    build(1,1,n);
    rep(i,1,n+1){
        ll l=i,r=n,mid;
        while(r-l>1){
            mid=(l+r)/2;
            if(check(i,mid))l=mid;
            else r=mid;
        }
        if(check(i,r))ans[r-l+1].pb({i,r});
        else ans[l-i+1].pb({i,l});
    }
    auto it=ans.end();
    it--;
    outl(it->fi<<" "<<sz(it->se));
    for(auto i:it->se)outl(i.fi<<" "<<i.se);
}
void prep(){

}
int main(){
    io;
    ll t=1;
    // cin>>t;
    prep();
    fix(12);
    while(t--)
        solve();
    return 0;
}