package main import ( "bufio" "fmt" "os" "strconv" ) type collection struct { index []int val []int cols []*collection } var sc = bufio.NewScanner(os.Stdin) var rdr = bufio.NewReaderSize(os.Stdin, 1000000) func main() { sc.Split(bufio.ScanWords) n := nextInt() var nums []int for i := 0; i < n; i++ { nums = append(nums, nextInt()) } c := &collection{ val: nums, } dfs(c) for _, v := range c.cols { all := true for _, c := range v.cols { sub := false for _, r := range c.cols { if len(r.cols) == 0 { sub = true break } } if !sub { all = false break } } if all { s := fmt.Sprintf("%v", v.index) fmt.Println(s[1 : len(s)-1]) return } } fmt.Println(-1) } func dfs(c *collection) { stack := make([]*collection, 0, 1000) stack = append(stack, c) for len(stack) != 0 { c = stack[0] stack = stack[1:] for i := 0; i < len(c.val)-2; i++ { for j := i + 1; j < len(c.val)-1; j++ { for k := j + 1; k < len(c.val); k++ { if !check(c.val[i], c.val[j], c.val[k]) { continue } col := &collection{ index: []int{i, j, k}, } col.val = append(col.val, c.val[:i]...) col.val = append(col.val, c.val[i+1:j]...) col.val = append(col.val, c.val[j+1:k]...) col.val = append(col.val, c.val[k+1:]...) c.cols = append(c.cols, col) stack = append(stack, col) } } } } } func check(a, b, c int) bool { if (b < a && a < c) || (c < a && a < b) { return true } if (a < c && c < b) || (b < c && c < a) { return true } return false } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i } func nextInt64() int64 { i, _ := strconv.ParseInt(nextLine(), 10, 64) return i } func nextUint64() uint64 { i, _ := strconv.ParseUint(nextLine(), 10, 64) return i } func nextFloat() float64 { f, _ := strconv.ParseFloat(nextLine(), 64) return f } func readLine() string { buf := make([]byte, 0, 1000000) for { l, p, e := rdr.ReadLine() if e != nil { panic(e) } buf = append(buf, l...) if !p { break } } return string(buf) }