import math._ object Main { def isValid(a: Int, b: Int, c: Int): Boolean = return (a < b && b > c) || (a > b && b < c) def calc(turn: Int, xs: Array[Int]): Boolean = { // if (xs.length < 3) { // return turn % 2 == 1 // } val ys = Array.fill(xs.length-3)(0) for (i <- 0 to xs.length-1) { for (j <- i+1 to xs.length-1) { for (k <- j+1 to xs.length-1) { if (isValid(xs(i), xs(j), xs(k))) { var p = 0 for (m <- 0 to xs.length-1) { if (m != i && m != j && m != k) { ys(p) = xs(m) p += 1 } } // println(s"take turn:$turn ${xs(i)} ${xs(j)} ${xs(k)}") val ret = calc(turn+1, ys) if (turn % 2 == 0) { if (ret) { if (turn == 0) { println(s"$i $j $k") } return true } } else { if (!ret) return false } } } } } return turn % 2 == 1 } def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val n = sc.nextInt val xs = Array.fill(n)(sc.nextInt) val win = calc(0, xs) if (!win) println(-1) } }