#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 100;   int t, cnt[N];   int mx;   int check(int row, int col, int n, int m) {     if (row < 0 || row >= n || col < 0 || col >= m) return 0;     int i = 0, j = 0, ok = 1;     for (; i < n; i++) {       for (j = 0; j < m; j++) {         if (!cnt[abs(row - i) + abs(col - j)]--) {           ok = 0;           break;         }       }       if (!ok) break;     }     if (ok) {       cout << n <<     << m << endl;       cout << row + 1 <<     << col + 1 << endl;       return 1;     }     for (int a = 0; a <= i; a++)       for (int b = 0; b < m && (a != i || b <= j); b++)         ++cnt[abs(row - a) + abs(col - b)];     return 0;   }   bool solve(int row, int n, int m, int mxi, int mxj) {     if (check(row, mxj - (mx - abs(row - mxi)), n, m)) return 1;     return check(row, mxj + (mx - abs(row - mxi)), n, m);   }   int main() {     scanf( %d , &t);     for (int i = 0; i < t; ++i) {       int v;       scanf( %d , &v);       ++cnt[v];       mx = max(mx, v);     }     if (cnt[0] != 1) return puts( -1 );     int a;     if (cnt[1] != 4)       a = 0;     else {       a = 1;       while (cnt[a + 1] == (a + 1) * 4) a++;     }     for (int n = 1; n * n <= t; n++) {       if (t % n) continue;       int m = t / n;       if (solve(a, n, m, 0, 0)) return 0;       if (solve(a, n, m, 0, m - 1)) return 0;       if (solve(a, n, m, n - 1, 0)) return 0;       if (solve(a, n, m, n - 1, m - 1)) return 0;       if (solve(a, m, n, 0, 0)) return 0;       if (solve(a, m, n, 0, n - 1)) return 0;       if (solve(a, m, n, m - 1, 0)) return 0;       if (solve(a, m, n, m - 1, n - 1)) return 0;     }     return puts( -1 );   }   