{"raw_statement":[{"iden":"statement","content":"Since Sonya has just learned the basics of matrices, she decided to play with them a little bit.\n\nSonya imagined a new type of matrices that she called _rhombic matrices_. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The cells with equal numbers have the form of a rhombus, that is why Sonya called this type so.\n\nThe Manhattan distance between two cells ($x_1$, $y_1$) and ($x_2$, $y_2$) is defined as $|x_1 - x_2| + |y_1 - y_2|$. For example, the Manhattan distance between the cells $(5, 2)$ and $(7, 1)$ equals to $|5-7|+|2-1|=3$.\n\n<center>![image](https://espresso.codeforces.com/e5764ac7f1d5e07fbcee4a81703c64e28865f285.png) Example of _a rhombic matrix_.</center>Note that _rhombic matrices_ are uniquely defined by $n$, $m$, and the coordinates of the cell containing the zero.\n\nShe drew a $n\\times m$ _rhombic matrix_. She believes that you can not recreate the matrix if she gives you only the elements of this matrix in some arbitrary order (i.e., the sequence of $n\\cdot m$ numbers). Note that Sonya will not give you $n$ and $m$, so only the sequence of numbers in this matrix will be at your disposal.\n\nWrite a program that finds such an $n\\times m$ _rhombic matrix_ whose elements are the same as the elements in the sequence in some order."},{"iden":"input","content":"The first line contains a single integer $t$ ($1\\leq t\\leq 10^6$) — the number of cells in the matrix.\n\nThe second line contains $t$ integers $a_1, a_2, \\ldots, a_t$ ($0\\leq a_i&lt; t$) — the values in the cells in arbitrary order."},{"iden":"output","content":"In the first line, print two positive integers $n$ and $m$ ($n \\times m = t$) — the size of the matrix.\n\nIn the second line, print two integers $x$ and $y$ ($1\\leq x\\leq n$, $1\\leq y\\leq m$) — the row number and the column number where the cell with $0$ is located.\n\nIf there are multiple possible answers, print any of them. If there is no solution, print the single integer $-1$."},{"iden":"examples","content":"Input\n\n20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n\nOutput\n\n4 5\n2 2\n\nInput\n\n18\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1\n\nOutput\n\n3 6\n2 3\n\nInput\n\n6\n2 1 0 2 1 2\n\nOutput\n\n\\-1"},{"iden":"note","content":"You can see the solution to the first example in the legend. You also can choose the cell $(2, 2)$ for the cell where $0$ is located. You also can choose a $5\\times 4$ matrix with zero at $(4, 2)$.\n\nIn the second example, there is a $3\\times 6$ matrix, where the zero is located at $(2, 3)$ there.\n\nIn the third example, a solution does not exist."}],"translated_statement":[{"iden":"statement","content":"由于索尼娅刚刚学习了矩阵的基础知识，她决定稍微玩一玩矩阵。\n\n索尼娅想象了一种她称为 _菱形矩阵_ 的新类型矩阵。这些矩阵恰好包含一个零，而其他所有单元格的值等于该单元格到包含零的单元格的曼哈顿距离。具有相同数值的单元格形成菱形，因此索尼娅称其为这种类型。\n\n两个单元格 ($x_1$, $y_1$) 和 ($x_2$, $y_2$) 之间的曼哈顿距离定义为 $| x_1 -x_2 | + | y_1 -y_2 |$。例如，单元格 $(5, 2)$ 和 $(7, 1)$ 之间的曼哈顿距离为 $| 5 -7 | + | 2 -1 | = 3$。\n\n注意，_菱形矩阵_ 由 $n$、$m$ 以及包含零的单元格的坐标唯一确定。\n\n她画出了一个 $n \\times m$ 的 _菱形矩阵_。她认为，如果你仅得到该矩阵元素的某种任意顺序（即 $n \\cdot m$ 个数字的序列），你就无法重建该矩阵。注意，索尼娅不会告诉你 $n$ 和 $m$，因此你只能获得矩阵中数字的序列。\n\n编写一个程序，找出一个 $n \\times m$ 的 _菱形矩阵_，其元素与给定序列中的元素相同（顺序任意）。\n\n第一行包含一个整数 $t$ ($1 \\leq t \\leq 10^6$) — 矩阵中的单元格数量。\n\n第二行包含 $t$ 个整数 $a_1, a_2, \\dots, a_t$ ($0 \\leq a_i < t$) — 按任意顺序给出的单元格中的值。\n\n第一行输出两个正整数 $n$ 和 $m$ ($n \\times m = t$) — 矩阵的尺寸。\n\n第二行输出两个整数 $x$ 和 $y$ ($1 \\leq x \\leq n$, $1 \\leq y \\leq m$) — 包含零的单元格所在的行号和列号。\n\n如果有多个可能的答案，输出任意一个即可。如果没有解，输出单个整数 $-1$。\n\n第一个示例的解法见题面图示。你也可以选择单元格 $(2, 2)$ 作为零的位置，也可以选择一个 $5 \\times 4$ 的矩阵，零位于 $(4, 2)$。\n\n在第二个示例中，存在一个 $3 \\times 6$ 的矩阵，零位于 $(2, 3)$。\n\n在第三个示例中，无解。"},{"iden":"input","content":"第一行包含一个整数 $t$ ($1 \\leq t \\leq 10^6$) — 矩阵中的单元格数量。第二行包含 $t$ 个整数 $a_1, a_2, \\dots, a_t$ ($0 \\leq a_i < t$) — 按任意顺序给出的单元格中的值。"},{"iden":"output","content":"第一行输出两个正整数 $n$ 和 $m$ ($n \\times m = t$) — 矩阵的尺寸。第二行输出两个整数 $x$ 和 $y$ ($1 \\leq x \\leq n$, $1 \\leq y \\leq m$) — 包含零的单元格所在的行号和列号。如果有多个可能的答案，输出任意一个即可。如果没有解，输出单个整数 $-1$。"},{"iden":"examples","content":"输入\n20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n输出\n4 5\n2 2\n\n输入\n18\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1\n输出\n3 6\n2 3\n\n输入\n6\n2 1 0 2 1 2\n输出\n-1"},{"iden":"note","content":"第一个示例的解法见题面图示。你也可以选择单元格 $(2, 2)$ 作为零的位置，也可以选择一个 $5 \\times 4$ 的矩阵，零位于 $(4, 2)$。在第二个示例中，存在一个 $3 \\times 6$ 的矩阵，零位于 $(2, 3)$。在第三个示例中，无解。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ t \\in \\mathbb{Z}^+ $ be the total number of cells in the matrix.  \nLet $ A = \\{a_1, a_2, \\dots, a_t\\} $ be a multiset of non-negative integers with $ 0 \\leq a_i < t $, representing the multiset of values in the rhombic matrix in arbitrary order.\n\nA *rhombic matrix* of size $ n \\times m $ (with $ n \\cdot m = t $) with zero at position $ (x, y) $ is defined such that for each cell $ (i, j) $, its value is the Manhattan distance to $ (x, y) $:  \n$$\nv(i,j) = |i - x| + |j - y|\n$$\n\n**Constraints**  \n1. $ t \\leq 10^6 $  \n2. $ a_i \\in \\mathbb{Z}_{\\geq 0} $, $ a_i < t $ for all $ i \\in \\{1, \\dots, t\\} $  \n3. $ n, m \\in \\mathbb{Z}^+ $, $ n \\cdot m = t $  \n4. $ 1 \\leq x \\leq n $, $ 1 \\leq y \\leq m $\n\n**Objective**  \nFind integers $ n, m, x, y $ such that:  \n- $ n \\cdot m = t $,  \n- The multiset of Manhattan distances $ \\{ |i - x| + |j - y| \\mid 1 \\leq i \\leq n,\\ 1 \\leq j \\leq m \\} $ is equal to the multiset $ A $.\n\nIf no such $ n, m, x, y $ exist, output $ -1 $.  \nIf multiple solutions exist, output any one.","simple_statement":null,"has_page_source":false}