#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    int a = i * 4;
    int ret[4];
    int* ter;
    if (i == t) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(2 * (i - r - 1), 2 * i - x - y);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(2 * (i - l - 1), 2 * i - x - y);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    int a[t];
    b = new int[t];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    if (i == 4) {
        i = 4;
    }
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t + 1) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
        return 0;
    }
    int a[t];
    b = new int[t + 1];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    if (i == 4) {
        i = 4;
    }
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t + 1) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    int a[t];
    b = new int[t + 1];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    if (b[0] != 1) {
        cout << -1;
        return 0;
    }
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
        return 0;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t + 1) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    int a[t];
    b = new int[t + 1];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    if (b[0] != 1) {
        cout << -1;
        return 0;
    }
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
        return 0;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    if (i == 4) {
        i = 4;
    }
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
        return 0;
    }
    int a[t];
    b = new int[t];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    //
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t + 1) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    scanf("%d", t);
    int* a = new int[t];
    b = new int[t + 1];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        int x;
        scanf("%d", x);
        a[i] = x;
        b[a[i]]++;
    }
    if (b[0] != 1) {
        cout << -1;
        return 0;
    }
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
        return 0;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    //
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t + 1) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    scanf("%d", t);
    int a[t];
    b = new int[t + 1];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        scanf("%d", a[i]);
        b[a[i]]++;
    }
    if (b[0] != 1) {
        cout << -1;
        return 0;
    }
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
        return 0;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    if (i == 4) {
        i = 4;
    }
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u - 1;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d - 1;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(i - r - 1, i - x - 1) + min(i - r - 1, i - y - 1);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(i - l - 1, i - x - 1) + min(i - l - 1, i - y - 1);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    if (t == 1) {
        cout << 1 << " " << 1 << endl << 1 << " " << 1;
    }
    int a[t];
    b = new int[t];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include <iostream>

using namespace std;

int* b;
int t;

int* lahenda(int u, int d, int r, int l, int i, int j) {
    int a = i * 4;
    int* ret = new int[4];
    int* ter;
    if (i == t) {
        ret[0] = u;
        ret[1] = d;
        ret[2] = r;
        ret[3] = l;
        return ret;
    }
    int x = 0, y = 0;
    if (u > -1 && u < i) {
        x = i - u;
        a -= 1 + 2 * (i - u - 1);
    }
    if (d > -1 && d < i) {
        y = i - d;
        a -= 1 + 2 * (i - d - 1);
    }
    if (r > -1 && r < i) {
        a -= 1 + min(2 * (i - r - 1), 2 * i - x - y);
    }
    if (l > -1 && l < i) {
        a -= 1 + min(2 * (i - l - 1), 2 * i - x - y);
    }
    int k = a - b[i];
    if (k > 4 - j || k < 0) {
        ret[0] = -1;
        return ret;
    }
    if (k == 0) {
        ter = lahenda(u, d, r, l, i + 1, j);
        return ter;
    }
    if (k == 1) {
        if (j == 0) {
            ter = lahenda(i - 1, d, r, l, i + 1, j + 1);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 2) {
            if (r != -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                if (ter[0] != -1) {
                    return ter;
                }
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
            ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
            return ter;
        }
        if (j == 3) {
            if (l == -1) {
                ter = lahenda(u, d, r, i - 1, i + 1, j + 1);
                return ter;
            }
            if (r == -1) {
                ter = lahenda(u, d, i - 1, l, i + 1, j + 1);
                return ter;
            }
            if (d == -1) {
                ter = lahenda(u, i - 1, r, l, i + 1, j + 1);
                return ter;
            }
        }
    }
    if (k == 2) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, r, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(i - 1, d, i - 1, l, i + 1, j + 2);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, l, i + 1, j + 2);
            if (ter[0] != -1) {
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
        if (j == 2) {
            if (d == -1) {
                ter = lahenda(u, i - 1, r, i - 1, i + 1, j + 2);
                return ter;
            }
            ter = lahenda(u, d, i - 1, i - 1, i + 1, j + 2);
            return ter;
        }
    }
    if (k == 3) {
        if (j == 0) {
            ter = lahenda(i - 1, i - 1, i - 1, l, i + 1, j + 3);
            return ter;
        }
        if (j == 1) {
            ter = lahenda(u, i - 1, i - 1, i - 1, i + 1, j + 3);
            return ter;
        }
    }
    if (k == 4) {
        ter = lahenda(i - 1, i - 1, i - 1, i - 1, i + 1, j + 4);
        return ter;
    }
}

int main()
{
    int i;
    cin >> t;
    int a[t];
    b = new int[t];
    for (i = 0; i < t; i++) {
        b[i] = 0;
    }
    for (i = 0; i < t; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    int* ret = lahenda(-1, -1, -1, -1, 1, 0);
    if (ret[0] == -1) {
        cout << -1;
        return 0;
    }
    cout << ret[0] + ret[1] + 1 << " " << ret[2] + ret[3] + 1 << endl << ret[0] + 1 << " " << ret[3] + 1;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n)
{
    int t = arr.size();
    if(t % n) return false;
    int m = t/n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    bool f = 0;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        if(i == 0 && a == 212488) f =true;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(f) cout<<":)"<<endl;
    if(arr[0] != 1) return cout << -1 << endl,0;
    if(t == 1) return cout<<"1 1\n1 1"<<endl,0;
    int v = -1,u = -1;
    for(int i=1;i<t;i++)
    {
        if(4*i > arr[i])
        {
            v = i - 1;
            break;
        }
    }
    for(int i = v + 1;i<t;i++)
    {
        if(4 * i - (2*(i-v)-1) > arr[i])
        {
            u = i-1;
            break;
        }
    }
    int dow = -1;
    for(int i = u+1; i< t;i++)
    {
        if(4*i - min(((i-v)*2 - 1) + ((i-u)*2 - 1), i - 1 + i-u + i-v) > arr[i])
        {
            dow= i-1;
            break;
        }
    }
    if(f) cout<<v<<' '<<u<<' '<<dow<<endl;
    if( u >=0 && v >=0 && dow >=0 && check(arr, v, u, v + dow + 1)) return 0;
    if( u >=0 && v >=0 && dow >=0 && check(arr, u, v, u + dow + 1)) return 0;
    if(u >=0 && v >=0 && maxi - v>=0 && check(arr, v, maxi - v, u + v + 1)) return 0;
    cout<<-1<<endl;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n)
{
    int t = arr.size();
    if(t % n) return false;
    int m = t/n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(arr[0] != 1) return cout << -1 << endl,0;
    if(t == 1) return cout<<"1 1\n1 1"<<endl,0;
    int v = -1,u = -1;
    for(int i=1;i<t;i++)
    {
        if(4*i > arr[i])
        {
            v = i - 1;
            break;
        }
    }
    for(int i = v + 1;i<t;i++)
    {
        if(4 * i - (2*(i-v)-1) > arr[i])
        {
            u = i-1;
            break;
        }
    }
    int dow = -1;
    for(int i = u+1; i< t;i++)
    {
        if(4*i - min(((i-v)*2 - 1) + ((i-u)*2 - 1), i - 1 + i-u + i-v) > arr[i])
        {
            dow= i-1;
            break;
        }
    }
    if(t == 1e6) cout<<v<<' '<<u<<' '<<dow<<endl;
    if( u >=0 && v >=0 && dow >=0 && check(arr, v, u, v + dow + 1)) return 0;
    if(u >=0 && v >=0 && maxi - v>=0 && check(arr, v, maxi - v, u + v + 1)) return 0;
    cout<<-1<<endl;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n)
{
    int t = arr.size();
    if(t % n) return false;
    int m = t/n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    bool f = 0;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        if(i == 0 && a == 212488) f =true;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(arr[0] != 1) return cout << -1 << endl,0;
    if(t == 1) return cout<<"1 1\n1 1"<<endl,0;
    int v = -1,u = -1;
    for(int i=1;i<t;i++)
    {
        if(4*i > arr[i])
        {
            v = i - 1;
            break;
        }
    }
    for(int i = v + 1;i<t;i++)
    {
        if(4 * i - (2*(i-v)-1) > arr[i])
        {
            u = i-1;
            break;
        }
    }
    int dow = -1;
    for(int i = u+1; i< t;i++)
    {
        if(4*i - min(((i-v)*2 - 1) + ((i-u)*2 - 1), i - 1 + i-u + i-v) > arr[i])
        {
            dow= i-1;
            break;
        }
    }
    if(f) cout<<v<<' '<<u<<' '<<dow<<endl;
    if( u >=0 && v >=0 && dow >=0 && check(arr, v, u, v + dow + 1)) return 0;
    if( u >=0 && v >=0 && dow >=0 && check(arr, u, v, u + dow + 1)) return 0;
    if(u >=0 && v >=0 && maxi - v>=0 && check(arr, v, maxi - v, u + v + 1)) return 0;
    cout<<-1<<endl;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n)
{
    int t = arr.size();
    if(t % n) return false;
    int m = t/n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    bool f = 0;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        if(i == 0 && a == 212488) f =true;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(arr[0] != 1) return cout << -1 << endl,0;
    if(t == 1) return cout<<"1 1\n1 1"<<endl,0;
    if(f) cout<<":)"<<endl;
    int v = -1,u = -1;
    for(int i=1;i<t;i++)
    {
        if(4*i > arr[i])
        {
            v = i - 1;
            break;
        }
    }
    for(int i = v + 1;i<t;i++)
    {
        if(4 * i - (2*(i-v)-1) > arr[i])
        {
            u = i-1;
            break;
        }
    }
    int dow = -1;
    for(int i = u+1; i< t;i++)
    {
        if(4*i - min(((i-v)*2 - 1) + ((i-u)*2 - 1), i - 1 + i-u + i-v) > arr[i])
        {
            dow= i-1;
            break;
        }
    }
    if(f) cout<<v<<' '<<u<<' '<<dow<<endl;
    if( u >=0 && v >=0 && dow >=0 && check(arr, v, u, v + dow + 1)) return 0;
    if( u >=0 && v >=0 && dow >=0 && check(arr, u, v, u + dow + 1)) return 0;
    if(u >=0 && v >=0 && maxi - v>=0 && check(arr, v, maxi - v, u + v + 1)) return 0;
    cout<<-1<<endl;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n, int m)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(arr[0] != 1) return cout << -1 << endl,0;
    int v = 0;
    for(int i=1;i<t;i++){
        if(4*i > arr[i]){
            v = i - 1;
            break;
        }
    }
    for(int n = 1,y;n <=t;n++){
        if(t%n) continue;
        y = -1*(maxi - n - t/n + v + 2);
        if(check(arr, v, y, n, t/n)) return 0;
    }
    cout<<-1;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n)
{
    int t = arr.size();
    if(t % n) return false;
    int m = t/n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(arr[0] != 1) return cout << -1 << endl,0;
    if(t == 1) return cout<<"1 1\n1 1"<<endl,0;
    int v = -1,u = -1;
    for(int i=1;i<t;i++)
    {
        if(4*i > arr[i])
        {
            v = i - 1;
            break;
        }
    }
    for(int i = v + 1;i<t;i++)
    {
        if(4 * i - (2*(i-v)-1) > arr[i])
        {
            u = i-1;
            break;
        }
    }
    int dow = -1;
    for(int i = u+1; i< t;i++)
    {
        if(4*i - min(((i-v)*2 - 1) + ((i-u)*2 - 1), i - 1 + i-u + i-v) > arr[i])
        {
            dow= i-1;
            break;
        }
    }
    if( u >=0 && v >=0 && dow >=0 && check(arr, v, u, v + dow + 1)) return 0;
    if( u >=0 && v >=0 && dow >=0 && check(arr, u, v, u + dow + 1)) return 0;
    if(u >=0 && v >=0 && maxi - v>=0 && check(arr, v, maxi - v, u + v + 1)) return 0;
    cout<<-1<<endl;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9 + 7;

bool check(vi arr, int a, int b, int n)
{
    int t = arr.size();
    if(t % n) return false;
    int m = t/n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(--arr[abs(a - i) + abs(b - j)] < 0) return false;
        }
    }
    cout << n <<' ' << m<<endl;
    cout<< a + 1 <<' '<<b + 1 <<endl;
    return true;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int t, maxi = 0; cin >> t;
    vi arr(t,0);
    for(int i=0,a;i<t;i++)
    {
        cin >> a;
        maxi = max(maxi,a);
        arr[a]++;
    }
    if(arr[0] != 1) return cout << -1 << endl,0;
    if(t == 1) return cout<<"1 1\n1 1"<<endl,0;
    int v = -1,u = -1;
    for(int i=1;i<t;i++)
    {
        if(4*i > arr[i])
        {
            v = i - 1;
            break;
        }
    }
    for(int i = v + 1;i<t;i++)
    {
        if(4 * i - (2*(i-v)-1) > arr[i])
        {
            u = i-1;
            break;
        }
    }
    int dow = -1;
    for(int i = u+1; i< t;i++)
    {
        if(4*i - min(((i-v)*2 - 1) + ((i-u)*2 - 1), i - 1 + i-u + i-v) > arr[i])
        {
            dow= i-1;
            break;
        }
    }
    if( u >=0 && v >=0 && dow >=0 && check(arr, v, u, v + dow + 1)) return 0;
    if(u >=0 && v >=0 && maxi - v>=0 && check(arr, v, maxi - v, u + v + 1)) return 0;
    cout<<-1<<endl;
    return cout<<endl, 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
struct node
{
    int u, v, step;
};
int vis[N], tvis[N];
bool solve(int x, int y, int n, int m)
{
    memset(tvis, 0, sizeof(tvis));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int tmp = abs(x-i)+abs(y-j);
            tvis[tmp]++;
            if(tvis[tmp] > vis[tmp]) return 0;
        }
    }
    return 1;
}
int main()
{
    int n, num;
    scanf("%d", &n);
    memset(vis, 0, sizeof(vis));
    int Max = 0;
    for(int i = 0; i <n; i++)
    {
        scanf("%d", &num);
        Max = max(Max, num);
        vis[num]++;
    }
    int x = 1, y;
//    int flag = 0;
    for(int i = 1; i <= n; i++)
    {
//        if(vis[i] > i*4) {
//            flag = 1; break;
//        }
//        if(vis[i] == i*4) continue;
//        x = i; break;
        if(vis[i] && vis[i]%4) {
            x = i;
            break;
        }
    }
//    if(flag) {
//        printf("-1\n");
//        return 0;
//    }
    int sqr = sqrt(n);
    for(int i = 1; i <= sqr; i++)
    {
        if(n%i == 0) {
            y = i+n/i-x-Max;
            if(solve(x, y, i, n/i)) {
                printf("%d %d\n", i, n/i);
                printf("%d %d\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
struct node
{
    int u, v, step;
};
int vis[N], tvis[N];
bool solve(int x, int y, int n, int m)
{
    memset(tvis, 0, sizeof(tvis));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int tmp = abs(x-i)+abs(y-j);
            tvis[tmp]++;
            if(tvis[tmp] > vis[tmp]) return 0;
        }
    }
    return 1;
}
int main()
{
    int n, num;
    scanf("%d", &n);
    memset(vis, 0, sizeof(vis));
    int Max = 0;
    for(int i = 0; i <n; i++)
    {
        scanf("%d", &num);
        Max = max(Max, num);
        vis[num]++;
    }
    int x, y;
//    int flag = 0;
    for(int i = 1; i <= n; i++)
    {
//        if(vis[i] > i*4) {
//            flag = 1; break;
//        }
//        if(vis[i] == i*4) continue;
//        x = i; break;
        if(vis[i] && vis[i]%4) {
            x = i;
            break;
        }
    }
//    if(flag) {
//        printf("-1\n");
//        return 0;
//    }
    int sqr = sqrt(n);
    for(int i = 1; i <= sqr; i++)
    {
        if(n%i == 0) {
            y = i+n/i-x-Max;
            if(solve(x, y, i, n/i)) {
                printf("%d %d\n", i, n/i);
                printf("%d %d\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
struct node
{
    int u, v, step;
};
int vis[N], tvis[N];
bool solve(int x, int y, int n, int m)
{
    memset(tvis, 0, sizeof(tvis));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int tmp = abs(x-i)+abs(y-j);
            tvis[tmp]++;
            if(tvis[tmp] > vis[tmp]) return 0;
        }
    }
    return 1;
}
int main()
{
    int n, num;
    scanf("%d", &n);
    memset(vis, 0, sizeof(vis));
    int Max = 0;
    for(int i = 0; i <n; i++)
    {
        scanf("%d", &num);
        Max = max(Max, num);
        vis[num]++;
    }
    int flag = 0, x, y;
    for(int i = 1; i <= n; i++)
    {
        if(vis[i] > i*4) {
            flag = 1; break;
        }
        if(vis[i] == i*4) continue;
        x = i; break;
    }
    if(flag) {
        printf("-1\n");
        return 0;
    }
    int sqr = sqrt(n);
    for(int i = 1; i <= sqr; i++)
    {
        if(n%i == 0) {
            y = i+n/i-x-Max;
            if(solve(x, y, i, n/i)) {
                printf("%d %d\n", i, n/i);
                printf("%d %d\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
struct node
{
    int u, v, step;
};
int vis[N], tvis[N];
bool solve(int x, int y, int n, int m)
{
    memset(tvis, 0, sizeof(tvis));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int tmp = abs(x-i)+abs(y-j);
            tvis[tmp]++;
            if(tvis[tmp] > vis[tmp]) return 0;
        }
    }
    return 1;
}
int main()
{
    int n, num;
    scanf("%d", &n);
    memset(vis, 0, sizeof(vis));
    int Max = 0;
    for(int i = 0; i <n; i++)
    {
        scanf("%d", &num);
        Max = max(Max, num);
        vis[num]++;
    }
    int flag = 0, x, y;
    for(int i = 1; i <= n; i++)
    {
        if(vis[i] > i*4) {
            flag = 1; break;
        }
        if(vis[i] == i*4) continue;
        x = i; break;
    }
    if(flag) {
        printf("-1\n");
        return 0;
    }
    int sqr = sqrt(n);
    if(sqr*sqr>n) sqr--;
    for(int i = 1; i <= sqr; i++)
    {
        if(n%i == 0) {
            y = i+n/i-x-Max;
            if(solve(x, y, i, n/i)) {
                printf("%d %d\n", i, n/i);
                printf("%d %d\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
struct node
{
    int u, v, step;
};
int vis[N], tvis[N];
bool solve(int x, int y, int n, int m)
{
    memset(tvis, 0, sizeof(tvis));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int tmp = abs(x-i)+abs(y-j);
            tvis[tmp]++;
            if(tvis[tmp] > vis[tmp]) return 0;
        }
    }
    return 1;
}
int main()
{
    int n, num;
    scanf("%d", &n);
    memset(vis, 0, sizeof(vis));
    int Max = 0;
    for(int i = 0; i <n; i++)
    {
        scanf("%d", &num);
        Max = max(Max, num);
        vis[num]++;
    }
    int flag = 0, x = 0, y;
    for(int i = 1; i <= n; i++)
    {
        if(vis[i] > i*4) {
            flag = 1; break;
        }
        if(vis[i] == i*4) continue;
        x = i; break;
    }
    if(flag || !x) {
        printf("-1\n");
        return 0;
    }
    int sqr = sqrt(n);
    for(int i = 1; i <= n; i++)
    {
        if(n%i == 0) {
            y = i+n/i-x-Max;
            if(solve(x, y, i, n/i)) {
                printf("%d %d\n", i, n/i);
                printf("%d %d\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
map<int,int> res1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}

if (m1[0] != 1){
    cout << -1 << endl;
    return 0;
}

b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=10000;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=m){
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }

        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=i){
            bool l = 1;
            for (int i1=1;i1<=m;i1++){
                for (int j1=1;j1<=i;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << m << " " << i << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
map<int,int> res1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}
b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=1000;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=m){
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
map<int,int> res1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}
b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=1000;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=m){
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }

        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=m && y>=1 && y<=i){
            bool l = 1;
            for (int i1=1;i1<=m;i1++){
                for (int j1=1;j1<=i;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << m << " " << i << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
map<int,int> res1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}

if (m1[0] != 1){
    cout << -1 << endl;
    return 0;
}

b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=1000;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=m){
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }

        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=i){
            bool l = 1;
            for (int i1=1;i1<=m;i1++){
                for (int j1=1;j1<=i;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << m << " " << i << endl;
                cout << x << " " << y << endl;
                return 0;
            }

		m = t/i;
        y = i+m-b-x;
        int c = y;
        y = x;
        x = c;
        if (y>=1 && y<=m){
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }

        m = t/i;
        y = i+m-b-x;
        int c1 = y;
        y = x;
        x = c1;
        if (y>=1 && y<=i){
            bool l = 1;
            for (int i1=1;i1<=m;i1++){
                for (int j1=1;j1<=i;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << m << " " << i << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
map<int,int> res1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}

if (m1[0] != 1){
    cout << -1 << endl;
    return 0;
}

b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=1000000;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=m){
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }

        m = t/i;
        y = i+m-b-x;
        if (y>=1 && y<=i){
            bool l = 1;
            for (int i1=1;i1<=m;i1++){
                for (int j1=1;j1<=i;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << m << " " << i << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}
b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=t;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
            bool l = 1;
            map<int,int> res1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                    break;
                }
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
    }
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
int a[1110001];
int f[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}
b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=t;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
            bool l = 1;
            memset(f, 0, sizeof(f));
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    f[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != f[j]) {
                    l = 0;
                    break;
                }
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
    }
}

cout << -1 << endl;

return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int,int> m1;
map<int,int> res1;
int a[1110001];

signed main() {

int t,n,m,x=0,y;
int b;

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> t;

int maxx = 0;
for (int i=1;i<=t;i++){
    cin >> a[i];
    if (a[i] > maxx){
        maxx = a[i];
    }
    m1[a[i]]++;
}
b = maxx;

for (int i=1;i<=b;i++){
    if (m1[i]!=i*4){
        x = i;
        break;
    }
}

if (x == 0) {
    x = 1;
}

for (int i=1;i<=t;i++){
    if (t%i == 0){
        m = t/i;
        y = i+m-b-x;
            bool l = 1;
            for (int i1=1;i1<=i;i1++){
                for (int j1=1;j1<=m;j1++){
                    res1[abs(i1-x)+abs(j1-y)]++;
                }
            }
            for (int j=0;j<=b;j++){
                if (m1[j] != res1[j]) {
                    l = 0;
                }
                res1[j] = 0;
            }
            if (l == 1){
                cout << i << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
    }
}

cout << -1 << endl;

return 0;
}


#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

map<int, int> frequency;

bool works(int n, int m, int r, int c) {
    unordered_map<int, int> my_freq;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int d = abs(i - r) + abs(j - c);
            my_freq[d]++;

            if (my_freq[d] > frequency[d])
                return false;
        }

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second != my_freq[it->first])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;

    for (int i = 0; i < T; i++) {
        int number;
        cin >> number;
        frequency[number]++;
    }

    int maximum = frequency.rbegin()->first;
    int distance = maximum + 1;

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second < 4 * it->first) {
            distance = it->first;
            break;
        }

    vector<tuple<int, int, int, int>> candidates;

    for (int n = 1; n * n <= T; n++)
        if (T % n == 0) {
            int m = T / n;
            candidates.push_back(make_tuple(n, m, distance - 1, maximum - (n - distance)));
            candidates.push_back(make_tuple(m, n, distance - 1, maximum - (m - distance)));
        }

    for (auto t : candidates) {
        int n, m, r, c;
        tie(n, m, r, c) = t;

        if (works(n, m, r, c)) {
            cout << n << ' ' << m << '\n';
            cout << r + 1 << ' ' << c + 1 << '\n';
            return 0;
        }
    }

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


#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

map<int, int> frequency;

bool works(int n, int m, int r, int c) {
    unordered_map<int, int> my_freq;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int d = abs(i - r) + abs(j - c);
            my_freq[d]++;

            if (my_freq[d] > frequency[d])
                return false;
        }

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second != my_freq[it->first])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;

    for (int i = 0; i < T; i++) {
        int number;
        cin >> number;
        frequency[number]++;
    }

    if (frequency[0] != 1) {
        cout << -1 << '\n';
        return 0;
    }

    int maximum = frequency.rbegin()->first;
    int distance = maximum + 1;

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second < 4 * it->first) {
            distance = it->first;
            break;
        }

    vector<tuple<int, int, int, int>> candidates;

    for (int n = 1; n * n <= T; n++)
        if (T % n == 0) {
            int m = T / n;
            candidates.push_back(make_tuple(n, m, distance - 1, maximum - (n - distance)));
            candidates.push_back(make_tuple(m, n, distance - 1, maximum - (m - distance)));
        }

    for (auto t : candidates) {
        int n, m, r, c;
        tie(n, m, r, c) = t;

        if (works(n, m, r, c)) {
            cout << n << ' ' << m << '\n';
            cout << r + 1 << ' ' << c + 1 << '\n';
            return 0;
        }
    }

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


#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

map<int, int> frequency;

bool works(int n, int m, int r, int c) {
    unordered_map<int, int> my_freq;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int d = abs(i - r) + abs(j - c);
            my_freq[d]++;

            if (my_freq[d] > frequency[d])
                return false;
        }

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second != my_freq[it->first])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;

    for (int i = 0; i < T; i++) {
        int number;
        cin >> number;
        frequency[number]++;
    }

    assert(frequency[0] == 1);
    int maximum = frequency.rbegin()->first;
    int distance = maximum + 1;

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second < 4 * it->first) {
            distance = it->first;
            break;
        }

    vector<tuple<int, int, int, int>> candidates;

    for (int n = 1; n * n <= T; n++)
        if (T % n == 0) {
            int m = T / n;
            candidates.push_back(make_tuple(n, m, distance - 1, maximum - (n - distance)));
            candidates.push_back(make_tuple(m, n, distance - 1, maximum - (m - distance)));
        }

    for (auto t : candidates) {
        int n, m, r, c;
        tie(n, m, r, c) = t;

        if (works(n, m, r, c)) {
            cout << n << ' ' << m << '\n';
            cout << r + 1 << ' ' << c + 1 << '\n';
            return 0;
        }
    }

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


#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

map<int, int> frequency;

bool works(int n, int m, int r, int c) {
    unordered_map<int, int> my_freq;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int d = abs(i - r) + abs(j - c);
            my_freq[d]++;

            if (my_freq[d] > frequency[d])
                return false;
        }

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second != my_freq[it->first])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;

    for (int i = 0; i < T; i++) {
        int number;
        cin >> number;
        frequency[number]++;
    }

    assert(frequency[0] == 1);
    int distance = -1;

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second < 4 * it->first) {
            distance = it->first;
            break;
        }

    int maximum = frequency.rbegin()->first;
    vector<tuple<int, int, int, int>> candidates;

    for (int n = 1; n * n <= T; n++)
        if (T % n == 0) {
            int m = T / n;
            candidates.push_back(make_tuple(n, m, distance - 1, maximum - (n - distance)));
            candidates.push_back(make_tuple(m, n, distance - 1, maximum - (m - distance)));
        }

    for (auto t : candidates) {
        int n, m, r, c;
        tie(n, m, r, c) = t;

        if (works(n, m, r, c)) {
            cout << n << ' ' << m << '\n';
            cout << r + 1 << ' ' << c + 1 << '\n';
            return 0;
        }
    }

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


#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

map<int, int> frequency;

bool works(int n, int m, int r, int c) {
    unordered_map<int, int> my_freq;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int d = abs(i - r) + abs(j - c);
            my_freq[d]++;

            if (my_freq[d] > frequency[d])
                return false;
        }

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second != my_freq[it->first])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;

    for (int i = 0; i < T; i++) {
        int number;
        cin >> number;
        frequency[number]++;
    }

    int maximum = frequency.rbegin()->first;
    int distance = maximum + 1;

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second < 4 * it->first) {
            distance = it->first;
            break;
        }

    vector<tuple<int, int, int, int>> candidates;

    for (int n = 1; n * n <= T; n++)
        if (T % n == 0)
            candidates.push_back(make_tuple(n, T / n, distance - 1, maximum - (n - distance)));

    for (auto t : candidates) {
        int n, m, r, c;
        tie(n, m, r, c) = t;

        if (works(n, m, r, c)) {
            cout << n << ' ' << m << '\n';
            cout << r + 1 << ' ' << c + 1 << '\n';
            return 0;
        }
    }

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


#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

map<int, int> frequency;

bool works(int n, int m, int r, int c) {
    unordered_map<int, int> my_freq;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int d = abs(i - r) + abs(j - c);
            my_freq[d]++;

            if (my_freq[d] > frequency[d])
                return false;
        }

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second != my_freq[it->first])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;

    for (int i = 0; i < T; i++) {
        int number;
        cin >> number;
        frequency[number]++;
    }

    int maximum = frequency.rbegin()->first;
    int distance = maximum + 1;

    for (auto it = frequency.begin(); it != frequency.end(); it++)
        if (it->second < 4 * it->first) {
            distance = it->first;
            break;
        }

    vector<tuple<int, int, int, int>> candidates;

    for (int n = 1; n * n <= T; n++)
        if (T % n == 0) {
            int m = T / n;
            // candidates.push_back(make_tuple(n, m, distance - 1, maximum - (n - distance)));
            candidates.push_back(make_tuple(m, n, distance - 1, maximum - (m - distance)));
        }

    for (auto t : candidates) {
        int n, m, r, c;
        tie(n, m, r, c) = t;

        if (works(n, m, r, c)) {
            cout << n << ' ' << m << '\n';
            cout << r + 1 << ' ' << c + 1 << '\n';
            return 0;
        }
    }

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


#include<bits/stdc++.h>

using namespace std;

#define N 1000005

int T, c[N], cnt[N];

int main()
{
	scanf("%d", &T);
	int maxn = 0;
	for(int i = 1; i <= T; i++)
	{
		int x;
		scanf("%d", &x);
		c[x]++;
		maxn = max(maxn, x);
	}
	if(T == 1 && c[0] == 1)
	{
		cout << 1 << ' ' << 1 << ' ' << 1 << ' ' << 1 << endl;
		return 0;
	}
	int x = 0;
	for(int i = 1; i <= maxn; i++)
		if(c[i] != 4 * i)
		{
			x = i;
			break;
		}
	for(int i = 1; i * i <= T; i++)
	{
		if(T % i != 0) continue;
		int n = i, m = T / i;
		int y = n + m - x - maxn;
		if(x > n || y > m || y < 0) continue;

		for(int i = 1; i <= n + m; i++) cnt[i] = 0;
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= m; k++)
			{
				cnt[abs(j - x) + abs(k - y)]++;
			}
		bool flag = 1;
		for(int i = 1; i <= maxn; i++)
			if(c[i] != cnt[i])
			{
				flag = 0;
				break;
			}
		if(flag)
		{
			cout << n << ' ' << m << endl << x << ' ' << y << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define N 1000005

int T, c[N], cnt[N];

int main()
{
	scanf("%d", &T);
	int maxn = 0;
	for(int i = 1; i <= T; i++)
	{
		int x;
		scanf("%d", &x);
		c[x]++;
		maxn = max(maxn, x);
	}
	if(T == 1 && c[0] == 1)
	{
		cout << 1 << ' ' << 1 << ' ' << 1 << ' ' << 1 << endl;
		return 0;
	}
	int x = 0;
	for(int i = 1; i <= maxn; i++)
		if(c[i] != 4 * i)
		{
			x = i;
			break;
		}
	for(int i = 1; i <= T; i++)
	{
		if(T % i != 0) continue;
		int n = i, m = T / i;
		int y = n + m - x - maxn;
		if(x > n || y > m || y < 0) continue;

		for(int i = 1; i <= n + m; i++) cnt[i] = 0;
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= m; k++)
			{
				cnt[abs(j - x) + abs(k - y)]++;
			}
		bool flag = 1;
		for(int i = 1; i <= maxn; i++)
			if(c[i] != cnt[i])
			{
				flag = 0;
				break;
			}
		if(flag)
		{
			cout << n << ' ' << m << endl << x << ' ' << y << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define N 1000005

int T, c[N], cnt[N];

int main()
{
	scanf("%d", &T);
	int maxn = 0;
	for(int i = 1; i <= T; i++)
	{
		int x;
		scanf("%d", &x);
		c[x]++;
		maxn = max(maxn, x);
	}
	if(T == 1 && c[0] == 1)
	{
		cout << 1 << ' ' << 1 << ' ' << 1 << ' ' << 1 << endl;
		return 0;
	}
	int x = 0;
	for(int i = 1; i <= maxn; i++)
		if(c[i] != 4 * i)
		{
			x = i;
			break;
		}
	int tmp = sqrt(T);
	for(int i = 1; i <= tmp; i++)
	{
		if(T % i != 0) continue;
		int n = i, m = T / i;
		int y = n + m - x - maxn;
		if(abs(n - x) + abs(m - y) != maxn) continue;

		for(int i = 1; i <= n + m; i++) cnt[i] = 0;
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= m; k++)
			{
				cnt[abs(j - x) + abs(k - y)]++;
			}
		bool flag = 1;
		for(int i = 1; i <= maxn; i++)
			if(c[i] != cnt[i])
			{
				flag = 0;
				break;
			}
		if(flag)
		{
			cout << n << ' ' << m << endl << x << ' ' << y << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define N 1000005

int T, c[N], cnt[N];

int main()
{
	scanf("%d", &T);
	int maxn = 0;
	for(int i = 1; i <= T; i++)
	{
		int x;
		scanf("%d", &x);
		c[x]++;
		maxn = max(maxn, x);
	}
	if(T == 1 && c[0] == 1)
	{
		cout << 1 << ' ' << 1 << ' ' << 1 << ' ' << 1 << endl;
		return 0;
	}
	int x = 0;
	for(int i = 1; i <= maxn; i++)
		if(c[i] != 4 * i)
		{
			x = i;
			break;
		}
	int tmp = sqrt(T);
	for(int i = 1; i <= tmp; i++)
	{
		if(T % i != 0) continue;
		int n = i, m = T / i;
		int y = n + m - x - maxn;
		if(x > n || y > m || y < 0) continue;

		for(int i = 1; i <= n + m; i++) cnt[i] = 0;
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= m; k++)
			{
				cnt[abs(j - x) + abs(k - y)]++;
			}
		bool flag = 1;
		for(int i = 1; i <= maxn; i++)
			if(c[i] != cnt[i])
			{
				flag = 0;
				break;
			}
		if(flag)
		{
			cout << n << ' ' << m << endl << x << ' ' << y << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define N 1000005

int T, c[N], cnt[N];

int main()
{
	scanf("%d", &T);
	int maxn = 0;
	for(int i = 1; i <= T; i++)
	{
		int x;
		scanf("%d", &x);
		c[x]++;
		maxn = max(maxn, x);
	}
	int x = 0;
	for(int i = 1; i <= maxn; i++)
		if(c[i] != 4 * i)
		{
			x = i;
			break;
		}
	int tmp = sqrt(T);
	for(int i = 1; i <= tmp; i++)
	{
		if(T % i != 0) continue;
		int n = i, m = T / i;
		int y = n + m - x - maxn;
		if(x > n || y > m || y < 0) continue;

		for(int i = 1; i <= n + m; i++) cnt[i] = 0;
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= m; k++)
			{
				cnt[abs(j - x) + abs(k - y)]++;
			}
		bool flag = 1;
		for(int i = 1; i <= maxn; i++)
			if(c[i] != cnt[i])
			{
				flag = 0;
				break;
			}
		if(flag)
		{
			cout << n << ' ' << m << endl << x << ' ' << y << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 1000001
int box[maxn], arr[maxn], tbox[maxn];
int b,t,flg;

void fill(int n,int m,int x, int y) {
    memcpy(tbox,box,sizeof(box));
    for(int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++) {
            int dis = abs(i-x) + abs(j-y);
            if (!tbox[dis]) return;
            tbox[dis] --;
        }
    flg = 1;
    printf("%d %d\n%d %d\n",n,m,x,y);
}

int main() {
    int x;
    scanf("%d", &t);
    for (int i = 1; i <= t; i ++) {
        scanf("%d", &x);
        box[x] ++;
        b = max(b, x);
    }
    x = 1;
    for (int i = 1; i <= b; i ++) {
        if (4*i != box[i]) {
            x = i;
            break;
        }
    }
    for (int i = 1; i*i <= t && !flg; i++) {
        if (t/i != 0) continue;
        int j = t/i;
        int y = i + j -b -x;
        fill(i,j,x,y);
        if (flg) break;
        fill(j,i,x,y);
    }
    if (!flg) puts("-1");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 1000001
int box[maxn], arr[maxn], tbox[maxn];
int b,t,flg;

void fill(int n,int m,int x, int y) {
    memcpy(tbox,box,sizeof(box));
    for(int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++) {
            int dis = abs(i-x) + abs(j-y);
            if (!tbox[dis]) return;
            tbox[dis] --;
        }
    flg = 1;
    printf("%d %d\n%d %d\n",n,m,x,y);
}

int main() {
    int x;
    scanf("%d", &t);
    for (int i = 1; i <= t; i ++) {
        scanf("%d", &x);
        box[x] ++;
        b = max(b, x);
    }
    x = 1;
    for (int i = 1; i <= b; i ++) {
        if (4*i != box[i]) {
            x = i;
            break;
        }
    }
    for (int i = 1; i*i <= t && !flg; i++) {
        int j = t/i;
        int y = i + j -b -x;
        fill(i,j,x,y);
        if (flg) break;
        fill(j,i,x,y);
    }
    if (!flg) puts("-1");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 1000001
int box[maxn], arr[maxn], tbox[maxn];
int b,t,flg;

void fill(int n,int m,int x, int y) {
    memcpy(tbox,box,sizeof(box));
    for(int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++) {
            int dis = abs(i-x) + abs(j-y);
            if (!tbox[dis]) return;
            tbox[dis] --;
        }
    flg = 1;
    printf("%d %d\n%d %d\n",n,m,x,y);
}

int main() {
    int x;
    scanf("%d", &t);
    for (int i = 1; i <= t; i ++) {
        scanf("%d", &x);
        box[x] ++;
        b = max(b, x);
    }
    x = -1;
    for (int i = 1; i <= b; i ++) {
        if (4*i != box[i]) {
            x = i;
            break;
        }
    }
    for (int i = 1; i*i <= t && !flg; i++) {
        int j = t/i;
        int y = i + j -b -x;
        fill(i,j,x,y);
        if (flg) break;
        fill(j,i,x,y);
    }
    if (!flg) puts("-1");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 1000001
int box[maxn], arr[maxn], tbox[maxn];
int b,t,flg;

void fill(int n,int m,int x, int y) {
    memcpy(tbox,box,sizeof(box));
    for(int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++) {
            int dis = abs(i-x) + abs(j-y);
            if (!tbox[dis]) return;
            tbox[dis] --;
        }
    flg = 1;
    printf("%d %d\n%d %d\n",n,m,x,y);
}

int main() {
    int x;
    scanf("%d", &t);
    for (int i = 1; i <= t; i ++) {
        scanf("%d", &x);
        box[x] ++;
        b = max(b, x);
    }
    x = 1;
    for (int i = 1; i <= b; i ++) {
        if (4*i != box[i]) {
            x = i;
            break;
        }
    }
    for (int i = 1; i*i <= t && !flg; i++) {
        if (t%i != 0) continue;
        int j = t/i;
        int y = i + j -b -x;
        fill(i,j,x,y);
        if (flg) break;
        fill(j,i,x,y);
    }
    if (!flg) puts("-1");
    return 0;
}


#include<bits/stdc++.h>
#define maxn 1234567

using namespace std;
int c[maxn],b[maxn],n,r,s,p;

bool check(int n,int m){
    s=n+m-p-r;
    for (int i=0;i<=p;i++) b[i]=0;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) b[abs(r-i)+abs(s-j)]++;
    for (int i=0;i<=p;i++) if (c[i]!=b[i]) return false;
    cout << n << ' ' << m << endl;
    cout << r << ' ' << s << endl;
    return true;
}

int main(){
    cin >> n;
    for (int i=0;i<n;i++){
        scanf("%d",&r);
        p=max(p,r); c[r]++;
    }
    for (int i=n;i;i--) if (c[i]!=i*4) r=i;
    for (int i=1;i*i<=n;i++) if (n%i==0){
        if (check(i,n/i)) return 0;
        if (check(n/i,i)) return 0;
    }
    cout << -1 << endl;
}


#include<bits/stdc++.h>
#define maxn 1234567

using namespace std;
int c[maxn],b[maxn],n,r,s,p;

bool check(int n,int m){
    s=n+m-p-r;
    for (int i=0;i<=p;i++) b[i]=0;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) b[abs(r-i)+abs(s-j)]++;
    for (int i=0;i<=p;i++) if (c[i]!=b[i]) return false;
    return true;
}

int main(){
    cin >> n;
    for (int i=0;i<n;i++){
        scanf("%d",&r);
        p=max(p,r); c[r]++;
    }
    for (int i=n;i;i--) if (c[i]!=i*4) r=i;
    for (int i=1;i*i<=n;i++) if (n%i==0){
        if (check(i,n/i)) return 0;
        if (check(n/i,i)) return 0;
    }
    cout << -1 << endl;
}


#include<bits/stdc++.h>
#define maxn 1234567

using namespace std;
int c[maxn],b[maxn],n,r,s,p;

bool check(int n,int m){
    s=n+m-p-r;
    if (r>n||s>m||s<1) return false;
    for (int i=0;i<=p;i++) b[i]=0;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) b[abs(r-i)+abs(s-j)]++;
    for (int i=0;i<=p;i++) if (c[i]!=b[i]) return false;
    cout << n << ' ' << m << endl;
    cout << r << ' ' << s << endl;
    return true;
}

int main(){
    cin >> n;
    for (int i=0;i<n;i++){
        scanf("%d",&r);
        p=max(p,r); c[r]++;
    }
    for (int i=n;i;i--) if (c[i]!=i*4) r=i;
    for (int i=1;i*i<=n;i++) if (n%i==0){
        if (check(i,n/i)) return 0;
        if (check(n/i,i)) return 0;
    }
    cout << -1 << endl;
}


#include<bits/stdc++.h>
#define maxn 1234567

using namespace std;
int c[maxn],b[maxn],n,r,s,p;

bool check(int n,int m){
    s=n+m-p-r;
    for (int i=0;i<=r;i++) b[i]=0;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) b[abs(r-i)+abs(s-j)]++;
    for (int i=0;i<=r;i++) if (c[i]!=b[i]) return false;
    cout << n << ' ' << m << endl;
    cout << r << ' ' << s << endl;
    return true;
}

int main(){
    cin >> n;
    for (int i=0;i<n;i++){
        scanf("%d",&r);
        p=max(p,r); c[r]++;
    }
    for (int i=n;i;i--) if (c[i]!=i*4) r=i;
    for (int i=1;i*i<=n;i++) if (n%i==0){
        if (check(i,n/i)) return 0;
        if (check(n/i,i)) return 0;
    }
    cout << -1 << endl;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	for(int i=1;i<=n;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=1;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	int p=sqrt(n);
	p=min(p,ma);
	for(int i=2*mi+1;i<=p+2;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=0;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	int p=sqrt(n);
	p=min(p,ma);
	for(int i=2*mi+1;i<n;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=0;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	for(int i=2*mi+1;i<=ma;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=1;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	int p=sqrt(n);
	p=min(p,ma);
	for(int i=2*mi+1;i<=n;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=0;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	for(int i=1;i<=n;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=0;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	int p=sqrt(n);
	p=min(p,ma);
	for(int i=2*mi+1;i<=p+1;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=0;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long
#define maxn 1000010
#define maxm 100004
#define inf 0x7f7f7f7f
const int mod=1e9+7;

int n,c[maxn],t[maxn],s[maxn];
int x,y,a,b;

inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
int ma,mi;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]),t[c[i]]++,ma=max(ma,c[i]);

	for(int i=1;i<=ma;i++)
		if(t[i]!=4*i){
			mi=i-1;
			break;
		}
	int p=sqrt(n);
	p=min(p,ma);
	for(int i=2*mi+1;i<=p;i++){
		if(n%i) continue;
		x=i;y=n/i;
		a=mi+1;b=x+y-ma-mi-1;
		memset(s,0,sizeof(s));
		for(int j=1;j<=x;j++){
			for(int k=1;k<=y;k++){
				s[abs(j-a)+abs(k-b)]++;
			}
		}
		bool flag=false;
		for(int j=1;j<=ma;j++){
			if(s[j]!=t[j]){
				flag=true;
			}
		}
		if(flag==false){
			cout<<x<<" "<<y<<endl;
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}
	puts("-1");

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N], cnt[N], t, tcnt[N];
void wrong_answer() {
    cout << -1 << endl;
    exit(0);
}
int ma;
bool check() {
    for(int i = 0; i <= ma; i++)
        if(cnt[i] != tcnt[i]) return false;
    return true;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> t;
    ma = 0;
    for(int i = 1; i <= t; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        ma = max(ma, a[i]);
    }
    if(t == 1) {
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    if(cnt[0] != 1) {
        cout << -1 << endl;
        return 0;
    }
    int x = -1, y = -1;
    for(int i = 1; i < t; i++)
        if(cnt[i] != 4 * i && x == -1) {
            x = i;
            break;
        }
    //cout << x << " " << y << endl;
    for(int i = 1; i <= sqrt(t); i++) {
        if(t % i == 0) {
            int n = i, m = t / i;
            y = m + n - ma - x;
            //cout << n << " " << m << endl;
            //cout << x << " " << y << endl;
            memset(tcnt, 0, sizeof tcnt);
            for(int i = 1; i <= n; i++)
                for(int j = 1; j <= m; j++) {
                    tcnt[abs(i - x) + abs(j - y)]++;
                }
            if(check()) {
                cout << n << " " << m << endl;
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}