import math._ object Main { def isValid(a: Int, b: Int, c: Int): Boolean = return (a < b && b > c) || (a > b && b < c) // xs.length <= 12 なのでメモ化しなくても間に合う def calc(turn: Int, xs: Array[Int]): Boolean = { 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))) { val ys = for (m <- 0 to xs.length-1 if m != i && m != j && m != k) yield xs(m) val ret = calc(turn+1, ys.toArray) 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) } }