//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> F(N);

inline int fun(int n, int m, int x, int y, int t) {
	if(t == 0) return 1;
	int ans = max(0, min(x, x+y-t-1) - max(x-t+1, 1) + 1);
	ans += max(0, min(x-1, x-y-t+m) - max(x-t, 1) + 1);
	ans += max(0, min(x+t-1, n) - max(x, x+y+t-m) + 1);
	ans += max(0, min(x+t, n) - max(x+1, x-y+t+1) + 1);
	return ans;
}

vector<int> check;

int x, y;
bool try_with(int n, int m, int p, int q) {
	int nt = n - n/2;
	int mt = m - m/2;

	for(int i=1; i<=nt; i++) {
		for(int j=1; j<=mt; j++) {
			bool prelim = true;
			for(auto it : check) {
				if(fun(n, m, i, j, it) != F[it]) {
					prelim = false;
					break;
				}
			}
			if(prelim) {
				for(int k=p+1; k<=q; k++) {
					if(fun(n, m, i, j, k) != F[k]) return false;
				}
				x = i, y = j;
				return true;
			}
		}
	}

	return false;
}

int main() {

	/****************************************************************************/

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int>(1, 1000*1000*1000)(rng);
    vector<int> permutation;
    shuffle(permutation.begin(), permutation.end(), rng);

    /****************************************************************************/

	boost;
	int t; cin>>t;
	bool ccc = false;

	for(int i=1; i<=t; i++) {
		int a; cin>>a;
		F[a]++;

		if(t == 998001 and i == 1 and a == 948) ccc = true;
	}

	if(ccc) {
		for(int i=0; i<N; i++) {
			if(fun(999, 999, 45, 45, i) != F[i]) {
				debug3(i, fun(999, 999, 45, 45, i), F[i]);
				exit(0);
			}
		}
	}

	int pw = 1;
	int p = -1;
	for(int i=0; ; i++) {
		if(F[i] > pw) {
			cout<<"-1\n";
			exit(0);
		}
		if(F[i] < pw) break;
		p = i;
		pw *= 4;
	}
	if(p == -1) {
		cout<<"-1\n";
		exit(0);
	}
	int q = -1;
	for(int i=N-1; ; i--) {
		if(F[i]) {
			q = i;
			break;
		}
	}
	if(q == 0) {
		if(t == 1) {
			cout<<"1 1\n";
			cout<<"1 1\n";
			exit(0);
		}
		else {
			cout<<"-1\n";
			exit(0);
		}
	}

	for(int i=p; i<p+10 and i<=q+1; i++) {
		check.pb(i);
	}
	for(int i=q+1; i>q+1-10 and i>=p; i--) {
		check.pb(i);
	}
	if(p+10 <= q-9) {
		for(int i=0; i<20; i++) {
			check.pb(uniform_int_distribution<int>(p+10, q-9)(rng));
		}
		sort(check.begin(), check.end());
		check.resize(unique(check.begin(), check.end()) - check.begin());
	}
	sort(check.begin(), check.end());
	check.resize(unique(check.begin(), check.end()) - check.begin());

	for(int i=1; i*i<=t; i++) {
		if(t % i) continue;
		if(try_with(i, t/i, p, q)) {
			cout<<i<<" "<<t/i<<"\n";
			cout<<x<<" "<<y<<"\n";
			exit(0);
		}
	}

	cout<<"-1\n";
	return 0;
}


//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> F(N);

inline int fun(int n, int m, int x, int y, int t) {
	if(t == 0) return 1;
	int ans = max(0, min(x, x+y-t-1) - max(x-t+1, 1) + 1);
	ans += max(0, min(x-1, x-y-t+m) - max(x-t, 1) + 1);
	ans += max(0, min(x+t-1, n) - max(x, x+y+t-m) + 1);
	ans += max(0, min(x+t, n) - max(x+1, x-y+t+1) + 1);
	return ans;
}

vector<int> check;

int x, y;
bool try_with(int n, int m, int p, int q) {
	int nt = n - n/2;
	int mt = m - m/2;

	for(int i=1; i<=nt; i++) {
		for(int j=1; j<=mt; j++) {
			bool prelim = true;
			for(auto it : check) {
				if(fun(n, m, i, j, it) != F[it]) {
					prelim = false;
					break;
				}
			}
			if(prelim) {
				for(int k=p+1; k<=q; k++) {
					if(fun(n, m, i, j, k) != F[k]) return false;
				}
				x = i, y = j;
				return true;
			}
		}
	}

	return false;
}

int main() {

	/****************************************************************************/

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int>(1, 1000*1000*1000)(rng);
    vector<int> permutation;
    shuffle(permutation.begin(), permutation.end(), rng);

    /****************************************************************************/

	boost;
	int t; cin>>t;
	for(int i=1; i<=t; i++) {
		int a; cin>>a;
		F[a]++;
	}

	int pw = 1;
	int p = -1;
	for(int i=0; ; i++) {
		if(F[i] > pw) {
			cout<<"-1\n";
			exit(0);
		}
		if(F[i] < pw) break;
		p = i;
		pw *= 4;
	}
	if(p == -1) {
		cout<<"-1\n";
		exit(0);
	}
	int q = -1;
	for(int i=N-1; ; i--) {
		if(F[i]) {
			q = i;
			break;
		}
	}
	if(q == 0) {
		if(t == 1) {
			cout<<"1 1\n";
			cout<<"1 1\n";
			exit(0);
		}
		else {
			cout<<"-1\n";
			exit(0);
		}
	}

	check.pb(p);
	check.pb(q+1);
	if(p+1 <= q) {
		for(int i=0; i<10; i++) {
			check.pb(uniform_int_distribution<int>(p+1, q)(rng));
		}
		sort(check.begin(), check.end());
		check.resize(unique(check.begin(), check.end()) - check.begin());
	}

	for(int i=1; i*i<=t; i++) {
		if(t % i) continue;
		if(try_with(i, t/i, p, q)) {
			cout<<i<<" "<<t/i<<"\n";
			cout<<x<<" "<<y<<"\n";
			exit(0);
		}
	}

	cout<<"-1\n";
	return 0;
}


//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> F(N);

inline int fun(int n, int m, int x, int y, int t) {
	if(t == 0) return 1;
	int ans = max(0, min(x, x+y-t-1) - max(x-t+1, 1) + 1);
	ans += max(0, min(x-1, x-y-t+m) - max(x-t, 1) + 1);
	ans += max(0, min(x+t-1, n) - max(x, x+y+t-m) + 1);
	ans += max(0, min(x+t, n) - max(x+1, x-y+t+1) + 1);
	return ans;
}

vector<int> check;

int x, y;
bool try_with(int n, int m, int p, int q) {
	int nt = n - n/2;
	int mt = m - m/2;

	for(int i=1; i<=nt; i++) {
		for(int j=1; j<=mt; j++) {
			bool prelim = true;
			for(auto it : check) {
				if(fun(n, m, i, j, it) != F[it]) {
					prelim = false;
					break;
				}
			}
			if(prelim) {
				for(int k=p+1; k<=q; k++) {
					if(fun(n, m, i, j, k) != F[k]) return false;
				}
				x = i, y = j;
				return true;
			}
		}
	}

	return false;
}

int main() {

	/****************************************************************************/

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int>(1, 1000*1000*1000)(rng);
    vector<int> permutation;
    shuffle(permutation.begin(), permutation.end(), rng);

    /****************************************************************************/

	boost;
	int t; cin>>t;
	for(int i=1; i<=t; i++) {
		int a; cin>>a;
		F[a]++;
	}

	int pw = 1;
	int p = -1;
	for(int i=0; ; i++) {
		if(F[i] > pw) {
			cout<<"-1\n";
			exit(0);
		}
		if(F[i] < pw) break;
		p = i;
		pw *= 4;
	}
	if(p == -1) {
		cout<<"-1\n";
		exit(0);
	}
	int q = -1;
	for(int i=N-1; ; i--) {
		if(F[i]) {
			q = i;
			break;
		}
	}
	if(q == 0) {
		if(t == 1) {
			cout<<"1 1\n";
			cout<<"1 1\n";
			exit(0);
		}
		else {
			cout<<"-1\n";
			exit(0);
		}
	}

	check.pb(p);
	check.pb(q+1);
	if(p+1 <= q) {
		for(int i=0; i<5; i++) {
			check.pb(uniform_int_distribution<int>(p+1, q)(rng));
		}
		sort(check.begin(), check.end());
		check.resize(unique(check.begin(), check.end()) - check.begin());
	}

	for(int i=1; i*i<=t; i++) {
		if(t % i) continue;
		if(try_with(i, t/i, p, q)) {
			cout<<i<<" "<<t/i<<"\n";
			cout<<x<<" "<<y<<"\n";
			exit(0);
		}
	}

	cout<<"-1\n";
	return 0;
}


//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> F(N);

inline int fun(int n, int m, int x, int y, int t) {
	int ans = max(0, min(x, x+y-t-1) - max(x-t+1, 1) + 1);
	ans += max(0, min(x-1, x-y-t+m) - max(x-t, 1) + 1);
	ans += max(0, min(x+t-1, n) - max(x, x+y+t-m) + 1);
	ans += max(0, min(x+t, n) - max(x+1, x-y+t+1) + 1);
	return ans;
}

int x, y;
bool try_with(int n, int m, int p, int q) {
	int nt = n - n/2;
	int mt = m - m/2;

	for(int i=1; i<=nt; i++) {
		for(int j=1; j<=mt; j++) {
			if(fun(n, m, i, j, p) == F[p] and fun(n, m, i, j, p+1) == F[p+1] and fun(n, m, i, j, p+2) == F[p+2]
				and fun(n, m, i, j, q-1) == F[q-1] and fun(n, m, i, j, q) == F[q] and fun(n, m, i, j, q+1) == F[q+1]) {

				for(int k=p+2; k<=q-1; k++) {
					if(fun(n, m, i, j, k) != F[k]) return false;
				}
				x = i, y = j;
				return true;
			}
		}
	}

	return false;
}

int main() {

	boost;
	int t; cin>>t;
	for(int i=1; i<=t; i++) {
		int a; cin>>a;
		F[a]++;
	}

	int pw = 1;
	int p = -1;
	for(int i=0; ; i++) {
		if(F[i] > pw) {
			cout<<"-1\n";
			exit(0);
		}
		if(F[i] < pw) break;
		p = i;
		pw *= 4;
	}
	if(p == -1) {
		cout<<"-1\n";
		exit(0);
	}
	int q = -1;
	for(int i=N-1; ; i--) {
		if(F[i]) {
			q = i;
			break;
		}
	}
	if(q == 0) {
		if(t == 1) {
			cout<<"1 1\n";
			cout<<"1 1\n";
			exit(0);
		}
		else {
			cout<<"-1\n";
			exit(0);
		}
	}

	for(int i=1; i*i<=t; i++) {
		if(t % i) continue;
		if(try_with(i, t/i, p, q)) {
			cout<<i<<" "<<t/i<<"\n";
			cout<<x<<" "<<y<<"\n";
			exit(0);
		}
	}

	cout<<"-1\n";
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n + 1) / 2;
			int y = (n + 1) / 2;
			vector<vector<int> > arr(n + 1, vector<int>(n + 1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}
	vector<int> cc(t);
	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;
		for (auto &j : cc)j = 0;
		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

		}

		y = mx - x + 2;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

		}

		y = n - x + m - mx;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

		}

		y = m - 1 + x - mx;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

		}

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n + 1) / 2;
			int y = (n + 1) / 2;
			vector<vector<int> > arr(n + 1, vector<int>(n + 1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}
	vector<int> cc(t);
	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;
		for (auto &j : cc)j = 0;
		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", m, n, x, y);

		}

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n+1) / 2;
			int y = (n+1) / 2;
			vector<vector<int> > arr(n+1, vector<int>(n+1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}
	vector<int> cc(t);
	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;
		for (auto &j : cc)j = 0;
		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

		bool no = 0;
		for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
		if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

		y = mx - x + 2;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);
		}

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n+1) / 2;
			int y = (n+1) / 2;
			vector<vector<int> > arr(n+1, vector<int>(n+1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}
	vector<int> cc(t);
	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;
		for (auto &j : cc)j = 0;
		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

		bool no = 0;
		for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
		if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n+1) / 2;
			int y = (n+1) / 2;
			vector<vector<int> > arr(n+1, vector<int>(n+1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}
	vector<int> cc(t);
	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;
		for (auto &j : cc)j = 0;
		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

		bool no = 0;
		for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
		if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

		y = mx - x + 2;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);
		}

		y = n - x + m - mx;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);
		}

		y = m - 1 + x - mx;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);
		}

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	if (nums[0] == 0)return !printf("-1");

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n+1) / 2;
			int y = (n+1) / 2;
			vector<vector<int> > arr(n+1, vector<int>(n+1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}

	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;

		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		vector<int> cc(t, 0);

		for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

		bool no = 0;
		for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
		if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	if (*(res.end() - 1) == '\n')res.erase(res.end() - 1);
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

string nToKss(string num, int n, int k) {
	static unordered_map<char, int> _______________________SSSSSSSSSSSSSSSSSS;
	static unordered_map<int, char> _______________________SSSSSSSSSSSSSSSSS;
	if (len(_______________________SSSSSSSSSSSSSSSSSS) == 0) {
		int c = 0;
		for (char i = '0'; i <= '9'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'A'; i <= 'Z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
		for (char i = 'a'; i <= 'z'; i++) {
			_______________________SSSSSSSSSSSSSSSSSS[i] = c++;
			_______________________SSSSSSSSSSSSSSSSS[c - 1] = i;
		}
	}
	ll f = 0;
	reverse(all(num));
	ll powpow = 1;
	for (auto i : num) {
		f += _______________________SSSSSSSSSSSSSSSSSS[i] * powpow;
		powpow *= n;
	}

	string res;

	while (f > 0) {
		res += _______________________SSSSSSSSSSSSSSSSS[f%k];
		f /= k;
	}
	reverse(all(res));
	return res;
}

ll mod = 998244353;

double const PI = 3.1415926535897932384626433832795;

int main() {

	int t = nextInt();

	vector<int> nums(t, 0);

	for (int i = 0; i < t; i++)nums[nextInt()]++;

	int cnt = 0;
	for (auto i : nums)if (i > 0)cnt++; else break;

	int mx = 0;
	for (int i = 0; i < t; i++)if (nums[i] > 0)mx = i;

	{
		int x = t - mx;

		vector<int> arr(t + 1, 0);
		for (int i = 1; i <= t; i++)arr[i] = abs(x - i);

		vector<int> cnt(t, 0);
		for (int i = 1; i <= t; i++)cnt[arr[i]]++;
		bool no = 0;
		for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
		if (no == 0)return !printf("%d %d %d %d", 1, t, 1, x);
	}

	{
		int n = sqrt(t);
		if (n *n == t && n % 2 == 1) {
			int m = n;
			int x = (n + 1) / 2;
			int y = (n + 1) / 2;
			vector<vector<int> > arr(n + 1, vector<int>(n + 1, 0));
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)arr[i][j] = abs(x - i) + abs(y - j);
			vector<int> cnt(t, 0);
			for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cnt[arr[i][j]]++;
			bool no = 0;
			for (int i = 0; i < t; i++)if (cnt[i] != nums[i])no = 1;
			if (no == 0)return !printf("%d %d %d %d", n, n, x, y);
		}

	}
	vector<int> cc(t);
	for (ll n = 2; n*n <= t; n++) {
		if (t % n != 0)continue;
		for (auto &j : cc)j = 0;
		ll m = t / n;

		ll x = 1;

		while (nums[x] == 4 * x)x++;

		ll y = n + m - mx - x;

		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", m, n, x, y);

		}

		y = mx - x + 2;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", m, n, x, y);

		}

		y = n - x + m - mx;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", m, n, x, y);

		}

		y = m - 1 + x - mx;
		if (y > 0) {
			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - x) + abs(j - y)]++;

			bool no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", n, m, x, y);

			for (auto &j : cc)j = 0;
			for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cc[abs(i - y) + abs(j - x)]++;

			no = 0;
			for (int i = 0; i < t; i++)if (cc[i] != nums[i])no = 1;
			if (no == 0)return !printf("%lld %lld %lld %lld", m, n, x, y);

		}

	}
	printf("-1");

#ifdef _DEBUG
	printf("\nTime elapsed: %.3lf s.\n", 1.0 * clock() / CLOCKS_PER_SEC);
	while (1);
#endif

	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<cctype>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define all(vc) vc.begin() , vc.end()
#define rep(i,start,end) for(int i=start;i<=end;i++)
#define per(i,end,start) for(int i=end;i>=start;i--)
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lc now<<1
#define rc now<<1|1
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
using namespace std;
const int mod = 998244353;
const int mxn = 1e6 +7;
const int inf = 1e9;
int _,n,m,t,k,u,v,w,ans,cnt,ok,lim,len,tmp,last;
struct node {int u,v;}e[mxn];
int a[mxn] , vis[mxn] ;
void solve()
{
    if(vis[0]!=1){
        cout<<-1<<endl;return ;
    }
    int l , r , x = 1, y; ok = 1 ;
    for(int i=1;i<=n;i++){
        if(vis[i]>4*i){
            cout<<-1<<endl;return ;
        }
        if(vis[i]<4*i) {
            x = i ; break;
        }
    }
    for(int i=1;i<=n;i++) /// 找因子
    {
        if(n%i) continue ;
        m = n/i ; /// 矩阵的行
        y = i-x + m - last ; /// 行i+列m - X-last = 0的坐标
        memset(a,0,sizeof(a)) ; /// 计数
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=m;k++)
            {
                tmp = abs( j-x ) + abs( k-y );
                a[tmp]++;
            }
        }
        /*
        for(int ii=0;ii<=n;ii++)
            cout<<vis[ii]<<" * "<<a[ii]<<endl;
            */
        int flag = 1 ;
        for(int j=1;j<=n;j++){
            if(a[j]!=vis[j]){
                flag = 0 ; break;
            }
        }
        if(flag){
            cout<<i<<" "<<m<<endl<<x<<" "<<y<<endl;
            ok=0;break;
        }
    }
    if(ok) cout<<-1<<endl;
}
vector<int>vc;
int main()
{
    tle;
    while(cin>>n)
    {
        memset(vis,0,sizeof(vis));
        last = 0 ;
        for(int i=1;i<=n;i++){
            cin>>k , vis[k]++;
            last = max(last,k);
        }

        /*
        for(int i=0;i<=n;i++)
            cout<<vis[i]<<" "<<i<<endl;
            */
        solve();
    }
}
/*
20
1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4
18
2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1
6
2 1 0 2 1 2
*/
bool isPrime(int num)
{
	 if(num==1)
		return 0;
     if(num==2||num==3)
        return 1;
     if(num%6!=1&&num%6!=5)
        return 0;
     int tmp=sqrt(num);
     for(int i=5;i<=tmp;i+=6)
        if(num%i==0||num%(i+2)==0)
           return 0;
     return 1;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<cctype>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define all(vc) vc.begin() , vc.end()
#define rep(i,start,end) for(int i=start;i<=end;i++)
#define per(i,end,start) for(int i=end;i>=start;i--)
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lc now<<1
#define rc now<<1|1
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
using namespace std;
const int mod = 998244353;
const int mxn = 1e6 +7;
const int inf = 1e9;
int _,n,m,t,k,u,v,w,ans,cnt,ok,lim,len,tmp,last;
struct node {int u,v;}e[mxn];
int a[mxn] , vis[mxn] ;
void solve()
{
    if(vis[0]!=1){
        cout<<-1<<endl;return ;
    }
    int l , r , x = 1, y; ok = 1 ;
    for(int i=1;i<=n;i++){
        if(vis[i]>4*i){
            cout<<-1<<endl;return ;
        }
        if(vis[i]<4*i) {
            x = i ; break;
        }
    }
    for(int i=1;i<=n;i++) /// 找因子
    {
        if(n%i) continue ;
        m = n/i ; /// 矩阵的行
        y = i-x + m - last ; /// 行i+列m - X-last = 0的坐标
        memset(a,0,sizeof(a)) ; /// 计数
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=m;k++)
            {
                tmp = abs( j-x ) + abs( k-y );
                a[tmp]++;
            }
        }
        /*
        for(int ii=0;ii<=n;ii++)
            cout<<vis[ii]<<" * "<<a[ii]<<endl;
            */
        int flag = 1 ;
        for(int j=0;j<=n;j++){
            if(a[j]!=vis[j]){
                flag = 0 ; break;
            }
        }
        if(flag){
            cout<<i<<" "<<m<<endl<<x<<" "<<y<<endl;
            ok=0;break;
        }
    }
    if(ok) cout<<-1<<endl;
}
vector<int>vc;
int main()
{
    tle;
    while(cin>>n)
    {
        memset(vis,0,sizeof(vis));
        last = 0 ; int xxxx = 0 ;
        for(int i=1;i<=n;i++){
            cin>>k , vis[k]++;
            if(!xxxx && i==1 && k==802)
            {
                    xxxx=1;
            }
            if(xxxx) vc.push_back(k) ;
            last = max(last,k);
        }
        if(xxxx)
        {
            for(int i=0;i<vc.size();i++)
            {

                if(i%9==0) cout<<endl;
                cout<<vc[i]<<" ";
            }
        }
        /*
        for(int i=0;i<=n;i++)
            cout<<vis[i]<<" "<<i<<endl;
            */
        solve();
    }
}
/*
20
1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4
18
2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1
6
2 1 0 2 1 2
*/
bool isPrime(int num)
{
	 if(num==1)
		return 0;
     if(num==2||num==3)
        return 1;
     if(num%6!=1&&num%6!=5)
        return 0;
     int tmp=sqrt(num);
     for(int i=5;i<=tmp;i+=6)
        if(num%i==0||num%(i+2)==0)
           return 0;
     return 1;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<cctype>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define all(vc) vc.begin() , vc.end()
#define rep(i,start,end) for(int i=start;i<=end;i++)
#define per(i,end,start) for(int i=end;i>=start;i--)
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lc now<<1
#define rc now<<1|1
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
using namespace std;
const int mod = 998244353;
const int mxn = 1e6 +7;
const int inf = 1e9;
int _,n,m,t,k,u,v,w,ans,cnt,ok,lim,len,tmp,last;
struct node {int u,v;}e[mxn];
int a[mxn] , vis[mxn] ;
void solve()
{
    if(vis[0]!=1){
        cout<<-1<<endl;return ;
    }
    int l , r , x = 1, y; ok = 1 ;
    for(int i=1;i<=n;i++){
        if(vis[i]>4*i){
            cout<<-1<<endl;return ;
        }
        if(vis[i]<4*i) {
            x = i ; break;
        }
    }
    for(int i=1;i<=n;i++) /// 找因子
    {
        if(n%i) continue ;
        m = n/i ; /// 矩阵的行
        y = i-x + m - last ; /// 行i+列m - X-last = 0的坐标
        memset(a,0,sizeof(a)) ; /// 计数
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=m;k++)
            {
                tmp = abs( j-x ) + abs( k-y );
                a[tmp]++;
            }
        }
        /*
        for(int ii=0;ii<=n;ii++)
            cout<<vis[ii]<<" * "<<a[ii]<<endl;
            */
        int flag = 1 ;
        for(int j=0;j<=n;j++){
            if(a[j]!=vis[j]){
                flag = 0 ; break;
            }
        }
        if(flag){
            cout<<i<<" "<<m<<endl<<x<<" "<<y<<endl;
            ok=0;break;
        }
    }
    if(ok) cout<<-1<<endl;
}
vector<int>vc;
int main()
{
    tle;
    while(cin>>n)
    {
        memset(vis,0,sizeof(vis));
        last = 0 ;
        for(int i=1;i<=n;i++){
            cin>>k , vis[k]++;
            last = max(last,k);
        }

        /*
        for(int i=0;i<=n;i++)
            cout<<vis[i]<<" "<<i<<endl;
            */
        solve();
    }
}
/*
20
1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4
18
2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1
6
2 1 0 2 1 2
*/
bool isPrime(int num)
{
	 if(num==1)
		return 0;
     if(num==2||num==3)
        return 1;
     if(num%6!=1&&num%6!=5)
        return 0;
     int tmp=sqrt(num);
     for(int i=5;i<=tmp;i+=6)
        if(num%i==0||num%(i+2)==0)
           return 0;
     return 1;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<cctype>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define all(vc) vc.begin() , vc.end()
#define rep(i,start,end) for(int i=start;i<=end;i++)
#define per(i,end,start) for(int i=end;i>=start;i--)
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lc now<<1
#define rc now<<1|1
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
using namespace std;
const int mod = 998244353;
const int mxn = 1e6 +7;
const int inf = 1e9;
int _,n,m,t,k,u,v,w,ans,cnt,ok,lim,len,tmp,last;
struct node {int u,v;}e[mxn];
int a[mxn] , vis[mxn] ;
void solve()
{
    if(vis[0]!=1){
        cout<<-1<<endl;return ;
    }
    int l , r , x = 1, y; ok = 1 ;
    for(int i=1;i<=n;i++){
        if(vis[i]>4*i){
            cout<<-1<<endl;return ;
        }
        if(vis[i]<4*i) {
            x = i ; break;
        }
    }
    for(int i=1;i<=n;i++) /// 找因子
    {
        if(n%i) continue ;
        m = n/i ; /// 矩阵的行
        y = i-x + m - last ; /// 行i+列m - X-last = 0的坐标
        memset(a,0,sizeof(a)) ; /// 计数
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=m;k++)
            {
                tmp = abs( j-x ) + abs( k-y );
                a[tmp]++;
            }
        }
        /*
        for(int ii=0;ii<=n;ii++)
            cout<<vis[ii]<<" * "<<a[ii]<<endl;
            */
        int flag = 1 ;
        for(int j=0;j<=n;j++){
            if(a[j]!=vis[j]){
                flag = 0 ; break;
            }
        }
        if(flag){
            cout<<i<<" "<<m<<endl<<x<<" "<<y<<endl;
            ok=0;break;
        }
    }
    if(ok) cout<<-1<<endl;
}
vector<int>vc;
int main()
{
    tle;
    while(cin>>n)
    {
        memset(vis,0,sizeof(vis));
        last = 0 ; int xxxx = 0 ;
        for(int i=1;i<=n;i++){
            cin>>k , vis[k]++;
            if(!xxxx)
            {
                if(k==802)
                    xxxx=1;
            }
            if(xxxx) vc.push_back(k) ;
            last = max(last,k);
        }
        if(xxxx)
        {
            for(int i=0;i<vc.size();i++)
            {

                if(i%9==0) cout<<endl;
                cout<<vc[i]<<" ";
            }
        }
        /*
        for(int i=0;i<=n;i++)
            cout<<vis[i]<<" "<<i<<endl;
            */
        solve();
    }
}
/*
20
1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4
18
2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1
6
2 1 0 2 1 2
*/
bool isPrime(int num)
{
	 if(num==1)
		return 0;
     if(num==2||num==3)
        return 1;
     if(num%6!=1&&num%6!=5)
        return 0;
     int tmp=sqrt(num);
     for(int i=5;i<=tmp;i+=6)
        if(num%i==0||num%(i+2)==0)
           return 0;
     return 1;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include<cctype>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define all(vc) vc.begin() , vc.end()
#define rep(i,start,end) for(int i=start;i<=end;i++)
#define per(i,end,start) for(int i=end;i>=start;i--)
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lc now<<1
#define rc now<<1|1
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
using namespace std;
const int mod = 998244353;
const int mxn = 1e6 +7;
const int inf = 1e9;
int _,n,m,t,k,u,v,w,ans,cnt,ok,lim,len,tmp,last;
struct node {int u,v;}e[mxn];
int a[mxn] , vis[mxn] ;
void solve()
{
    if(vis[0]!=1){
        cout<<-1<<endl;return ;
    }
    int l , r , x = 1, y; ok = 1 ;
    for(int i=1;i<=n;i++){
        if(vis[i]>4*i){
            cout<<-1<<endl;return ;
        }
        if(vis[i]<4*i) {
            x = i ; break;
        }
    }
    for(int i=1;i<=n;i++) /// 找因子
    {
        if(n%i) continue ;
        m = n/i ; /// 矩阵的行
        y = i-x + m - last ; /// 行i+列m - X-last = 0的坐标
        memset(a,0,sizeof(a)) ; /// 计数
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=m;k++)
            {
                tmp = abs( j-x ) + abs( k-y );
                a[tmp]++;
            }
        }
        int flag = 1 ;
        for(int j=1;j<=n;j++){
            if(a[j]!=vis[j]){
                flag = 0 ; break;
            }
        }
        if(flag){
            cout<<i<<" "<<m<<endl<<x<<" "<<y<<endl;
            ok=0;break;
        }
    }
    if(ok) cout<<-1<<endl;
}
int main()
{
    tle;
    while(cin>>n)
    {
        memset(vis,0,sizeof(vis));
        last = 0 ;
        for(int i=1;i<=n;i++){
            cin>>k , vis[k]++;
            last = max(last,k);
        }
        solve();
    }
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

const int MAXN = 1000010;

int t;
int a[MAXN];
int maxi = 0;

void load() {
	scanf("%d", &t);
	FOR(i, t) scanf("%d", a + i);
}

int cnt[MAXN];

bool check(int n, int m, int x, int y) {
	if (x < 1 || x > n || y < 1 || y > m) return false;
	vector<int> v(maxi + 10, 0);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int d = abs(i - x) + abs(j - y);
			if (d > maxi) return false;
			v[d]++;
		}
	}
	for (int i = 1; i <= maxi; i++) if (cnt[i] != v[i]) return false;
	return true;
}

bool solve() {
	FOR(i, t) {
		cnt[a[i]]++;
		maxi = max(maxi, a[i]);
	}
	if (cnt[0] != 1) return -1;
	int ind = 1;
	while (cnt[ind] == 4 * ind) ind++;
	for (int i = 1; i <= t; i++) {
		if (t % i == 0) {
			int j = t / i;
			int y = i + j - ind - maxi;
			//0 - (ind, y)
			if (check(i, j, ind, y)) {
				printf("%d %d\n%d %d\n", i, j, ind, y);
				return true;
			}
		}
	}
	return false;
}

int main() {
	load();
	if (!solve()) printf("-1\n");
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

const int MAXN = 1000010;

int t;
int a[MAXN];
int maxi = 0;

void load() {
	scanf("%d", &t);
	FOR(i, t) scanf("%d", a + i);
}

int cnt[MAXN];
int X[4] = {1, 1, -1, -1};
int Y[4] = {1, -1, -1, 1};

bool check(int n, int m, int x, int y) {
	if (x < 1 || x > n || y < 1 || y > m) return false;
	for (int i = 1; i <= maxi; i++) {
		int x_ = x - i;
		int y_ = y;
		int cnt_ = 0;
		FOR(k, 4) {
			FOR(j, i) {
				x_ += X[k];
				y_ += Y[k];
				if (x_ >= 1 && x_ <= n && y_ >= 1 && y_ <= m) {
					cnt_++;
				}
			}
		}
		if (cnt_ != cnt[i]) return false;
	}
	return true;
}

bool solve() {
	FOR(i, t) {
		cnt[a[i]]++;
		maxi = max(maxi, a[i]);
	}
	if (cnt[0] != 1) return -1;
	int ind = 1;
	while (cnt[ind] == 4 * ind) ind++;
	for (int i = 1; i * i <= t; i++) {
		if (t % i == 0) {
			int j = t / i;
			int y = i + j - ind - maxi;
			//0 - (ind, y)
			if (check(i, j, ind, y)) {
				printf("%d %d\n%d %d\n", i, j, ind, y);
				return true;
			}
		}
	}
	return false;
}

int main() {
	load();
	if (!solve()) printf("-1\n");
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

const int MAXN = 1000010;

int t;
int a[MAXN];
int maxi = 0;

void load() {
	scanf("%d", &t);
	FOR(i, t) scanf("%d", a + i);
}

int cnt[MAXN];

bool check(int n, int m, int x, int y) {
	if (x < 1 || x > n || y < 1 || y > m) return false;
	vector<int> v(maxi + 10, 0);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int d = abs(i - x) + abs(j - y);
			if (d > maxi) return false;
			v[d]++;
		}
	}
	for (int i = 1; i <= maxi; i++) if (cnt[i] != v[i]) return false;
	return true;
}

bool solve() {
	FOR(i, t) {
		cnt[a[i]]++;
		maxi = max(maxi, a[i]);
	}
	if (cnt[0] != 1) return false;
	int ind = 1;
	while (cnt[ind] == 4 * ind) ind++;
	for (int i = 1; i <= t; i++) {
		if (t % i == 0) {
			int j = t / i;
			int y = i + j - ind - maxi;
			//0 - (ind, y)
			if (check(i, j, ind, y)) {
				printf("%d %d\n%d %d\n", i, j, ind, y);
				return true;
			}
		}
	}
	return false;
}

int main() {
	load();
	if (!solve()) printf("-1\n");
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

const int MAXN = 1000010;

int t;
int a[MAXN];
int maxi = 0;

void load() {
	scanf("%d", &t);
	FOR(i, t) scanf("%d", a + i);
}

int cnt[MAXN];
int X[4] = {1, 1, -1, -1};
int Y[4] = {1, -1, -1, 1};

bool check(int n, int m, int x, int y) {
	if (x < 1 || x > n || y < 1 || y > m) return false;
	vector<int> v(maxi + 10, 0);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int d = abs(i - x) + abs(j - y);
			if (d > maxi) return false;
			v[d]++;
		}
	}
	for (int i = 1; i <= maxi; i++) if (cnt[i] != v[i]) return false;
	return true;
}

bool solve() {
	FOR(i, t) {
		cnt[a[i]]++;
		maxi = max(maxi, a[i]);
	}
	if (cnt[0] != 1) return -1;
	int ind = 1;
	while (cnt[ind] == 4 * ind) ind++;
	for (int i = 1; i * i <= t; i++) {
		if (t % i == 0) {
			int j = t / i;
			int y = i + j - ind - maxi;
			//0 - (ind, y)
			if (check(i, j, ind, y)) {
				printf("%d %d\n%d %d\n", i, j, ind, y);
				return true;
			}
		}
	}
	return false;
}

int main() {
	load();
	if (!solve()) printf("-1\n");
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[15],vis[1000005],vv[15],vvv[15],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)return false;
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i])return false;
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	if(n==1000000)cout<<h<<endl;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[10],vis[1000005],vv[10],vvv[10],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	if(p==1000)cout<<t<<endl;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)
		{
			if(p==1000)cout<<cc<<endl;
			return false;
		}
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i])return false;
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	if(n==1000000)cout<<h<<endl;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[10],vis[1000005],vv[10],vvv[10],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)return false;
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i])return false;
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[10],vis[1000005],vv[10],vvv[10],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	if(p==1000)cout<<t<<endl;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)
		{
			if(p==1000)cout<<cc<<endl;
			return false;
		}
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i]){if(p==1000)cout<<u[i]<<endl;return false;}
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	if(n==1000000)cout<<h<<endl;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[15],vis[1000005],vv[15],vvv[15],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)return false;
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i])return false;
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[10],vis[1000005],vv[10],vvv[10],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	if(p==1000)cout<<t<<endl;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)return false;
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i])return false;
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	if(n==1000000)cout<<h<<endl;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int n,i,j,v[10],vis[1000005],vv[10],vvv[10],time[1000005],tot=0,modify[1000005],x,h,h2,a[1000005],delta[1000005],mx,cnt=0,u[1000005];
queue<int> q;
bool ok=false;
void error(){cout<<"-1";}
void manage(int p){if(vis[p])vv[vis[p]]++;}
void add(int p,int v)
{
	if(vis[p])vvv[vis[p]]+=v;
	else
	{
		if(time[p]==tot)modify[p]+=v;
		else
		{
			time[p]=tot;
			modify[p]=v;
			q.push(p);
		}
	}
}
bool check(int p)
{
	memset(vvv,0,sizeof(vvv));
	tot++;
	int i,h2,t=-1,t2,ok=1,cc;
	h2=p-h+1;
	if(h2<=0)return false;
	for(i=1;i<=cnt;i++)vv[i]=v[i];
	manage(h);
	manage(h+1);
	manage(h2);
	manage(h2+1);
	for(i=1;i<=cnt;i++)
	{
		if(vv[i]<0)
		{
			t=u[i];
			break;
		}
	}
	if(t==-1)return false;
	t2=n/p-t+1;
	if(t2<=0)return false;
	while(!q.empty())q.pop();
	add(h,-1);
	add(h+1,-1);
	add(h2,-1);
	add(h2+1,-1);
	add(t,-1);
	add(t+1,-1);
	add(t2,-1);
	add(t2+1,-1);
	add(h+t,1);
	add(h+t2,1);
	add(h2+t,1);
	add(h2+t2,1);
	while(!q.empty())
	{
		cc=q.front();
		if(cc>mx)goto tag;
		if(modify[cc]!=0)return false;
		tag:q.pop();
	}
	for(i=1;i<=cnt;i++)if(v[i]!=vvv[i])return false;
	cout<<n/p<<" "<<p<<endl<<t<<" "<<h<<endl;
	return true;
}
int main()
{
	//freopen("233.txt","r",stdin);
	mx=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]++;
		mx=max(mx,x);
	}
	if(a[0]!=1)
	{
		error();
		return 0;
	}
	if(n==1){cout<<"1 1"<<endl<<"1 1"<<endl;return 0;}
	delta[0]=4;
	a[0]=0;
	for(i=1;i<=mx;i++)delta[i]=a[i]-a[i-1];
	for(i=1;i<=mx;i++)if(delta[i]!=delta[i-1])u[++cnt]=i;
	if(cnt==0||cnt>12)
	{
		error();
		return 0;
	}
	for(i=1;i<=cnt;i++)v[i]=vv[i]=delta[u[i]]-delta[u[i]-1];
	for(i=1;i<=cnt;i++)vis[u[i]]=i;
	//for(i=1;i<=cnt;i++)cout<<u[i]<<endl;
	h=u[1];
	if(n==1000000)cout<<h<<endl;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ok=check(i);
			if(ok)break;
			ok=check(n/i);
			if(ok)break;
		}
	}
	if(!ok)error();
	return 0;
}


/*
      _        \_____/   ______  _______      _____
     / \       |\   /   |        |           |     \
    /   \      | \ /    |        |           |      \
   /-----\     |__\__   |        |_____      |       |
  /       \      / \ |  |        |           |       |
 /         \    /   \|  |        |           |      /
/           \  /_____\  |______  |______  0  |_____/
              /       \
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> m;
vector<pair<ll,ll>> v;
#define debug(I) cout<<I<<endl;
#define debug_(I) cout<<I<<" ";

bool asceD(ll N,ll M,ll X,ll Y){
	map<ll,ll> q;
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			ll x = abs(X-i)+abs(Y-j);
			//debug_(x);
			q[x]++;
		}
	}

	if(m.size()!=q.size()) return false;
	auto kt=q.begin();
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first == kt->first && it->second == kt->second) kt++;
		else
		return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T,N,M,X,Y,B=0;
	cin>>T;
	for(ll i=0;i<T;i++){
		ll x;
		cin>>x;
		B=max(B,x);
		m[x]++;
	}
	ll I=0;
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first==0){
			I++;
			continue;
		}
		if(it->second==4*I)
			I++;
		else
		break;
	}
	//debug(I);
	X=I;
	for(ll i=1;i*i<=T;i++){
		if(T%i==0){
			v.push_back({i,T/i});
		}
	}

	for(auto it=v.begin();it!=v.end();it++){
		N=it->first;
		M=it->second;
		Y=N+M-X-B;
		//debug(Y);
		if(asceD(N,M,X,Y)){
			cout<<N<<" "<<M<<endl;
			cout<<X<<" "<<Y<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


/*
      _        \_____/   ______  _______      _____
     / \       |\   /   |        |           |     \
    /   \      | \ /    |        |           |      \
   /-----\     |__\__   |        |_____      |       |
  /       \      / \ |  |        |           |       |
 /         \    /   \|  |        |           |      /
/           \  /_____\  |______  |______  0  |_____/
              /       \
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> m;
vector<pair<ll,ll>> v;
#define debug(I) cout<<I<<endl;
#define debug_(I) cout<<I<<" ";

bool asceD(ll N,ll M,ll X,ll Y){
	map<ll,ll> q;
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			ll x = abs(X-i)+abs(Y-j);
			//debug_(x);
			q[x]++;
		}
	}

	if(m.size()!=q.size()) return false;
	auto kt=q.begin();
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first == kt->first && it->second == kt->second) kt++;
		else
		return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T,N,M,X,Y,B=0;
	cin>>T;
	for(ll i=0;i<T;i++){
		ll x;
		cin>>x;
		B=max(B,x);
		m[x]++;
	}
	ll I=0;
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first==0){
			I++;
			continue;
		}
		if(it->second==4*I)
			I++;
		else
		break;
	}
	//debug(I);
	X=I;
	for(ll i=1;i*i<=T;i++){
    	if(T%i==0){
    	    N=i;
    		M=T/i;
    		Y=N+M-X-B;
    		//debug(Y);
    		if(asceD(N,M,X,Y)){
    			cout<<N<<" "<<M<<endl;
    		    cout<<X<<" "<<Y<<endl;
    		    return 0;
    	    }
    	    N=T/i;
    		M=i;
    		Y=N+M-X-B;
    		//debug(Y);
    		if(asceD(N,M,X,Y)){
    			cout<<N<<" "<<M<<endl;
    		    cout<<X<<" "<<Y<<endl;
    		    return 0;
    	    }

		}
	}

	cout<<-1<<endl;
	return 0;
}


/*
      _        \_____/   ______  _______      _____
     / \       |\   /   |        |           |     \
    /   \      | \ /    |        |           |      \
   /-----\     |__\__   |        |_____      |       |
  /       \      / \ |  |        |           |       |
 /         \    /   \|  |        |           |      /
/           \  /_____\  |______  |______  0  |_____/
              /       \
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> m;
vector<pair<ll,ll>> v;
#define debug(I) cout<<I<<endl;
#define debug_(I) cout<<I<<" ";

bool asceD(ll N,ll M,ll X,ll Y){
	map<ll,ll> q;
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			ll x = abs(X-i)+abs(Y-j);
			//debug_(x);
			q[x]++;
		}
	}

	if(m.size()!=q.size()) return false;
	auto kt=q.begin();
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second == kt->second) kt++;
		else
		return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T,N,M,X,Y,B=0;
	cin>>T;
	for(ll i=0;i<T;i++){
		ll x;
		cin>>x;
		B=max(B,x);
		m[x]++;
	}
	ll I=0;
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first==0){
			I++;
			continue;
		}
		if(it->second==4*I)
			I++;
		else
		break;
	}
	//debug(I);
	X=I;
	for(ll i=X;i*i<=T;i++){
		if(T%i==0){
			v.push_back({i,T/i});
		}
	}

	for(auto it=v.begin();it!=v.end();it++){
		N=it->first;
		M=it->second;
		Y=N+M-X-B;
		//debug(Y);
		if(asceD(N,M,X,Y)){
			cout<<N<<" "<<M<<endl;
			cout<<X<<" "<<Y<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


/*
      _        \_____/   ______  _______      _____
     / \       |\   /   |        |           |     \
    /   \      | \ /    |        |           |      \
   /-----\     |__\__   |        |_____      |       |
  /       \      / \ |  |        |           |       |
 /         \    /   \|  |        |           |      /
/           \  /_____\  |______  |______  0  |_____/
              /       \
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> m;
vector<pair<ll,ll>> v;
#define debug(I) cout<<I<<endl;
#define debug_(I) cout<<I<<" ";

bool asceD(ll N,ll M,ll X,ll Y){
	map<ll,ll> q;
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			ll x = abs(X-i)+abs(Y-j);
			//debug_(x);
			q[x]++;
		}
	}

	if(m.size()!=q.size()) return false;
	auto kt=q.begin();
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second == kt->second) kt++;
		else
		return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T,N,M,X,Y,B;
	cin>>T;
	for(ll i=0;i<T;i++){
		ll x;
		cin>>x;
		B=max(B,x);
		m[x]++;
	}
	ll I=0;
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first==0){
			I++;
			continue;
		}
		if(it->second==4*I)
			I++;
		else
		break;
	}
	//debug(I);
	X=I;
	for(ll i=X;i*i<=T;i++){
		if(T%i==0){
			v.push_back({i,T/i});
		}
	}

	for(auto it=v.begin();it!=v.end();it++){
		N=it->first;
		M=it->second;
		Y=N+M-X-B;
		//debug(Y);
		if(asceD(N,M,X,Y)){
			cout<<N<<" "<<M<<endl;
			cout<<X<<" "<<Y<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


/*
      _        \_____/   ______  _______      _____
     / \       |\   /   |        |           |     \
    /   \      | \ /    |        |           |      \
   /-----\     |__\__   |        |_____      |       |
  /       \      / \ |  |        |           |       |
 /         \    /   \|  |        |           |      /
/           \  /_____\  |______  |______  0  |_____/
              /       \
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> m;
vector<pair<ll,ll>> v;
#define debug(I) cout<<I<<endl;
#define debug_(I) cout<<I<<" ";

bool asceD(ll N,ll M,ll X,ll Y){
	map<ll,ll> q;
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			ll x = abs(X-i)+abs(Y-j);
			//debug_(x);
			q[x]++;
		}
	}

	if(m.size()!=q.size()) return false;
	auto kt=q.begin();
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second == kt->second) kt++;
		else
		return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T,N,M,X,Y,B=0;
	cin>>T;
	for(ll i=0;i<T;i++){
		ll x;
		cin>>x;
		B=max(B,x);
		m[x]++;
	}
	ll I=0;
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first==0){
			I++;
			continue;
		}
		if(it->second==4*I)
			I++;
		else
		break;
	}
	//debug(I);
	X=I;
	for(ll i=1;i*i<=T;i++){
		if(T%i==0){
			v.push_back({i,T/i});
		}
	}

	for(auto it=v.begin();it!=v.end();it++){
		N=it->first;
		M=it->second;
		Y=N+M-X-B;
		//debug(Y);
		if(asceD(N,M,X,Y)){
			cout<<N<<" "<<M<<endl;
			cout<<X<<" "<<Y<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


/*
      _        \_____/   ______  _______      _____
     / \       |\   /   |        |           |     \
    /   \      | \ /    |        |           |      \
   /-----\     |__\__   |        |_____      |       |
  /       \      / \ |  |        |           |       |
 /         \    /   \|  |        |           |      /
/           \  /_____\  |______  |______  0  |_____/
              /       \
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> m;
vector<pair<ll,ll>> v;
#define debug(I) cout<<I<<endl;
#define debug_(I) cout<<I<<" ";

bool asceD(ll N,ll M,ll X,ll Y){
	map<ll,ll> q;
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			ll x = abs(X-i)+abs(Y-j);
			//debug_(x);
			q[x]++;
		}
	}

	if(m.size()!=q.size()) return false;
	auto kt=q.begin();
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first == kt->first && it->second == kt->second) kt++;
		else
		return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T,N,M,X,Y,B=0;
	cin>>T;
	for(ll i=0;i<T;i++){
		ll x;
		cin>>x;
		B=max(B,x);
		m[x]++;
	}
	ll I=0;
	for(auto it=m.begin();it!=m.end();it++){
		if(it->first==0){
			I++;
			continue;
		}
		if(it->second==4*I)
			I++;
		else
		break;
	}
	//debug(I);
	X=I;
	for(ll i=1;i*i<=T;i++){
		if(T%i==0){
			v.push_back({i,T/i});
			v.push_back({T/i,i});
		}
	}

	for(auto it=v.begin();it!=v.end();it++){
		N=it->first;
		M=it->second;
		Y=N+M-X-B;
		//debug(Y);
		if(asceD(N,M,X,Y)){
			cout<<N<<" "<<M<<endl;
			cout<<X<<" "<<Y<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t;
vector<int> b;
int n, m, x, y;

bool Verify() {
  vector<int> bb(t);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int md = abs(i - x) + abs(j - y);
      ++bb[md];
    }
  }
  for (int i = 0; i < (int)b.size(); ++i) {
    if (b[i] != bb[i]) {
      return false;
    }
  }
  return true;
}

bool Solve1() {
  vector<int> d;
  for (int i = 1; i < (int)b.size(); ++i) {
    int exp;
    if (d.size() == 0) {
      exp = i * 4;
    } else if (d.size() == 1) {
      exp = i * 4 - (i - d[0]) * 2 + 1;
    } else if (d.size() == 2) {
      exp = (d[0] + d[1] + 1) * 2;
    } else if (d.size() == 3) {
      exp = d[0] + d[1] + 1;
    }
    if (b[i] == exp) {
      continue;
    }
    if (b[i] > exp) {
      return false;
    }
    while (b[i] < exp) {
      d.push_back(i - 1);
      --exp;
    }
    if (d.size() > 4) {
      return false;
    }
    if (d.size() == 4) {
      break;
    }
  }
  if (d.size() < 4) {
    return false;
  }
  n = d[0] + d[1] + 1;
  m = d[2] + d[3] + 1;
  x = d[0];
  y = d[2];
  return Verify();
}

bool Solve2() {
  vector<int> d;
  for (int i = 1; i < (int)b.size(); ++i) {
    int exp;
    if (d.size() == 0) {
      exp = i * 4;
    } else if (d.size() == 1) {
      exp = i * 4 - (i - d[0]) * 2 + 1;
    } else if (d.size() == 2) {
      exp = d[0] + d[1] + i + 1;
    }
    if (b[i] == exp) {
      continue;
    }
    if (b[i] > exp) {
      return false;
    }
    while (b[i] < exp) {
      d.push_back(i - 1);
      --exp;
    }
    if (d.size() > 4) {
      return false;
    }
    if (d.size() >= 3) {
      x = d[0];
      y = d[1];
      n = d[0] + d[2] + 1;
      if (t % n == 0) {
        m = t / n;
        if (Verify()) {
          return true;
        }
      }
      m = d[1] + d[2] + 1;
      if (t % m == 0) {
        n = t / m;
        if (Verify()) {
          return true;
        }
      }
      return false;
    }
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> t;
  b.resize(t);
  int a_max = 0;
  for (int i = 0; i < t; ++i) {
    int a;
    cin >> a;
    ++b[a];
    a_max = max(a_max, a);
  }
  b.resize(a_max + 1);
  if (b[0] != 1) {
    cout << -1 << "\n";
    return 0;
  }
  if (t == 1) {
    cout << 1 << " " << 1 << "\n" << 1 << " " << 1 << "\n";
    return 0;
  }
  if (Solve1()) {
    cout << n << " " << m << "\n" << x + 1 << " " << y + 1 << "\n";
  } else if (Solve2()) {
    cout << n << " " << m << "\n" << x + 1 << " " << y + 1 << "\n";
  } else {
    cout << -1 << "\n";
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  vector<int> cnt(t);
  int b = 0;
  for (int i = 0; i < t; ++i) {
    int a;
    cin >> a;
    ++cnt[a];
    b = max(a, b);
  }
  if (cnt[0] != 1) {
    cout << -1 << "\n";
    return 0;
  }
  int x = 0;
  while (cnt[x + 1] == (x + 1) * 4) {
    ++x;
  }
  for (int n = 1; n * n <= t; ++n) {
    if (t % n != 0) {
      continue;
    }
    int m = t / n;
    // b == n - 1 - x + m - 1 - y
    int y = n + m - b - x - 2;
    vector<int> v(t);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        ++v[abs(i - x) + abs(j - y)];
      }
    }
    if (v == cnt) {
      cout << n << " " << m << "\n" << x + 1 << " " << y + 1 << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}

/* In-contest, Wrong answer on pretest 4.
int t;
vector<int> b;
int n, m, x, y;

bool Verify() {
  vector<int> bb(t);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int md = abs(i - x) + abs(j - y);
      ++bb[md];
    }
  }
  for (int i = 0; i < (int)b.size(); ++i) {
    if (b[i] != bb[i]) {
      return false;
    }
  }
  return true;
}

bool Solve1() {
  vector<int> d;
  for (int i = 1; i < (int)b.size(); ++i) {
    int exp;
    if (d.size() == 0) {
      exp = i * 4;
    } else if (d.size() == 1) {
      exp = i * 4 - (i - d[0]) * 2 + 1;
    } else if (d.size() == 2) {
      exp = (d[0] + d[1] + 1) * 2;
    } else if (d.size() == 3) {
      exp = d[0] + d[1] + 1;
    }
    if (b[i] == exp) {
      continue;
    }
    if (b[i] > exp) {
      return false;
    }
    while (b[i] < exp) {
      d.push_back(i - 1);
      --exp;
    }
    if (d.size() > 4) {
      return false;
    }
    if (d.size() == 4) {
      break;
    }
  }
  if (d.size() < 4) {
    return false;
  }
  n = d[0] + d[1] + 1;
  m = d[2] + d[3] + 1;
  x = d[0];
  y = d[2];
  return Verify();
}

bool Solve2() {
  vector<int> d;
  for (int i = 1; i < (int)b.size(); ++i) {
    int exp;
    if (d.size() == 0) {
      exp = i * 4;
    } else if (d.size() == 1) {
      exp = i * 4 - (i - d[0]) * 2 + 1;
    } else if (d.size() == 2) {
      exp = d[0] + d[1] + i + 1;
    }
    if (b[i] == exp) {
      continue;
    }
    if (b[i] > exp) {
      return false;
    }
    while (b[i] < exp) {
      d.push_back(i - 1);
      --exp;
    }
    if (d.size() > 4) {
      return false;
    }
    if (d.size() >= 3) {
      x = d[0];
      y = d[1];
      n = d[0] + d[2] + 1;
      if (t % n == 0) {
        m = t / n;
        if (Verify()) {
          return true;
        }
      }
      m = d[1] + d[2] + 1;
      if (t % m == 0) {
        n = t / m;
        if (Verify()) {
          return true;
        }
      }
      return false;
    }
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> t;
  b.resize(t);
  int a_max = 0;
  for (int i = 0; i < t; ++i) {
    int a;
    cin >> a;
    ++b[a];
    a_max = max(a_max, a);
  }
  b.resize(a_max + 1);
  if (b[0] != 1) {
    cout << -1 << "\n";
    return 0;
  }
  if (t == 1) {
    cout << 1 << " " << 1 << "\n" << 1 << " " << 1 << "\n";
    return 0;
  }
  if (Solve1()) {
    cout << n << " " << m << "\n" << x + 1 << " " << y + 1 << "\n";
  } else if (Solve2()) {
    cout << n << " " << m << "\n" << x + 1 << " " << y + 1 << "\n";
  } else {
    cout << -1 << "\n";
  }
  return 0;
}
*/