```go
package main
import (
"fmt"
"io"
"os"
)
func main() {
b, err := io.ReadAll(os.Stdin)
if err != nil {
return
}
var head int
for head < len(b) && b[head] <= 32 {
head++
}
if head >= len(b) {
return
}
readInt := func() int {
for head < len(b) && b[head] <= 32 {
head++
}
if head >= len(b) {
return 0
}
v := 0
for head < len(b) && b[head] > 32 {
v = v*10 + int(b[head]-'0')
head++
}
return v
}
t := readInt()
if t == 0 {
return
}
cnt := make([]int, t+1)
maxDist := 0
for i := 0; i < t; i++ {
a := readInt()
if a < 0 || a >= t {
fmt.Println("-1")
return
}
cnt[a]++
if a > maxDist {
maxDist = a
}
}
if cnt[0] != 1 {
fmt.Println("-1")
return
}
x := 1
for x <= maxDist && cnt[x] == 4*x {
x++
}
tempCnt := make([]int, maxDist+1)
for n := 1; n <= t; n++ {
if t%n != 0 {
continue
}
if x > n {
continue
}
m := t / n
dx := x - 1
if n-x > dx {
dx = n - x
}
dy := maxDist - dx
if dy < 0 {
continue
}
yCands := []int{dy + 1}
if dy+1 != m-dy {
yCands = append(yCands, m-dy)
}
for _, y := range yCands {
if y < 1 || y > m {
continue
}
for i := 0; i <= maxDist; i++ {
tempCnt[i] = 0
}
possible := true
for i := 1; i <= n && possible; i++ {
distX := i - x
if distX < 0 {
distX = -distX
}
for j := 1; j <= m; j++ {
distY := j - y
if distY < 0 {
distY = -distY
}
d := distX + distY
if d > maxDist {
possible = false
break
}
tempCnt[d]++
if tempCnt[d] > cnt[d] {
possible = false
break
}
}
}
if possible {
for i := 0; i <= maxDist; i++ {
if tempCnt[i] != cnt[i] {
possible = false
break
}
}
if possible {
fmt.Printf("%d %d\n%d %d\n", n, m, x, y)
return
}
}
}
}
fmt.Println("-1")
}
```