#include <bits/stdc++.h>
using namespace std;
#pragma optimize(2)
const int inf = 0x7FFFFFFF;
template <class T>
inline void MAX(T &x, T y) {
  if (y > x) x = y;
}
template <class T>
inline void MIN(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void rd(T &x) {
  x = 0;
  char o, f = 1;
  while (o = getchar(), o < 48)
    if (o == 45) f = -f;
  do x = (x << 3) + (x << 1) + (o ^ 48);
  while (o = getchar(), o > 47);
  x *= f;
}
template <class T>
void wt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) wt(x / 10);
  putchar('0' + x % 10);
}
const long long llinf = 4223372036854775807;
const long long mod = (0 ? 1000000007 : 998244353);
const long long mod2 = 999998639;
const long long m1 = 998244353;
const long long m2 = 1000001011;
const long long pr = 233;
const double eps = 1e-7;
const long long maxm = 1;
const long long maxn = 510000;
long long b[][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
struct lo {
  long long x, y, v;
  lo() {}
  lo(long long a, long long b, long long c) : x(a), y(b), v(c) {}
};
bool ck(long long x, long long y, long long n, long long m) {
  if (x < 1 || x > n) return false;
  if (y < 1 || y > m) return false;
  return true;
}
long long date[2100000];
long long ttt[2100000];
long long mp[2100000];
void work() {
  long long n;
  cin >> n;
  long long tmp;
  long long ma = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> tmp;
    MAX(ma, tmp);
    date[tmp]++;
  }
  long long x = 0;
  long long now = 4;
  for (long long i = 1; i <= n; i++) {
    if (date[i] != now) {
      x = i;
      break;
    }
    now += 4;
  }
  for (long long i = x; n / i >= x; i++) {
    if (n % i == 0) {
      long long nn = i, mm = n / i;
      long long y = nn + mm - x - ma;
      if (!ck(x, y, nn, mm)) continue;
      queue<lo> q;
      q.push(lo(x, y, 0));
      mp[x * mm + y] = nn;
      for (long long i = 0; i <= ma; i++) ttt[i] = 0;
      while (!q.empty()) {
        lo tt = q.front();
        ttt[tt.v]++;
        q.pop();
        for (long long i = 0; i < 4; i++) {
          if (ck(tt.x + b[i][0], tt.y + b[i][1], nn, mm) &&
              mp[(tt.x + b[i][0]) * mm + tt.y + b[i][1]] != nn) {
            q.push(lo(tt.x + b[i][0], tt.y + b[i][1], tt.v + 1));
            mp[(tt.x + b[i][0]) * mm + tt.y + b[i][1]] = nn;
          }
        }
      }
      long long flag = 0;
      for (long long i = 0; i <= ma; i++) {
        if (ttt[i] != date[i]) {
          flag = 1;
          break;
        }
      }
      if (!flag) {
        cout << nn << ' ' << mm << endl;
        cout << x << ' ' << y << endl;
        return;
      }
    }
  }
  cout << -1 << endl;
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    work();
  }
  return 0;
}
