#include <bits/stdc++.h>
using namespace std;
const int N = 1000011;
int t;
int freq[N];
int cur[N];
int mark[N];
int ini = 1;
int last;
int mx = 0;
int sum[N];
pair<int, int> check(int n, int m) {
  pair<int, int> cur = pair<int, int>(-1, -1);
  int line = last;
  if (n - line - 1 < line) return cur;
  if (m - last - 1 < last) return cur;
  int col_quero = n - 1 - last + m - 1 - mx;
  bool hav = 0;
  pair<int, int> certo = pair<int, int>(line, col_quero);
  for (int col = last; col < m - last; col++) {
    if (m - col - 1 < col) break;
    hav |= pair<int, int>(line, col) == certo;
  }
  if (!hav) return cur;
  memset(sum, 0, sizeof sum);
  for (int i = 0; i < m; i++) {
    int dist = abs(i - col_quero);
    sum[dist + 1]++;
    sum[dist + last + 1]--;
    sum[dist]++;
    sum[dist + (n - 1) - last + 1]--;
  }
  for (int i = 1; i <= t; i++) sum[i] += sum[i - 1];
  bool pod = 1;
  for (int i = 0; i <= t; i++) {
    pod &= sum[i] == freq[i];
  }
  if (pod)
    return certo;
  else
    return cur;
}
int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    int x;
    scanf("%d", &x);
    freq[x]++;
    mx = max(mx, x);
  }
  if (freq[0] != 1) {
    cout << -1;
    return 0;
  }
  while (freq[ini] == 4 * ini) ini++;
  last = ini - 1;
  for (int i = 1; 1ll * i * i <= t; i++) {
    if (t % i == 0) {
      pair<int, int> cur = check(t / i, i);
      if (cur != pair<int, int>(-1, -1)) {
        cout << t / i << ' ' << i << '\n';
        cout << cur.first + 1 << ' ' << cur.second + 1 << '\n';
        return 0;
      } else {
        cur = check(i, t / i);
        if (cur != pair<int, int>(-1, -1)) {
          cout << i << ' ' << t / i << '\n';
          cout << cur.first + 1 << ' ' << cur.second + 1 << '\n';
          return 0;
        }
      }
    }
  }
  cout << -1 << '\n';
  return 0;
}
