#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void test() {
  int r = 0;
  for (int i = 2; i * i <= 720720; i++) {
    if (720720 % i == 0) r += i;
  }
  cout << r << endl;
}
ll wid(ll h, ll w, ll x) {
  return h * (x * (x + 1) / 2 + (w - x) * (w - x - 1) / 2);
}
int n;
bool validate(vector<int> &V, int h, int w, int x, int y) {
  vector<int> ver;
  for (int i = 0; i < w; ++i)
    for (int j = 0; j < h; ++j) ver.push_back(abs(x - i) + abs(y - j));
  sort((ver).begin(), (ver).end());
  for (int i = 0; i < n; ++i)
    if (ver[i] != V[i]) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  vector<int> V(n);
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> V[i];
    sum += V[i];
  }
  sort((V).begin(), (V).end());
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ll h = i;
      ll w = n / i;
      int lim = (i + 1) / 2;
      for (int k = 0; k < lim; ++k) {
        ll tot = wid(w, h, k);
        int b = 0, e = (w + 1) / 2, t;
        ll p;
        while (b < e) {
          t = (b + e) / 2;
          p = tot + wid(h, w, t);
          if (p > sum) {
            b = t + 1;
          } else {
            e = t;
          }
        }
        p = tot + wid(h, w, b);
        if (p == sum && validate(V, w, h, k, b)) {
          cout << h << " " << w << endl << k + 1 << " " << b + 1 << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
}
