N = int(input()) K = list(map(int, input().split())) from itertools import combinations def solve(unused): l = [] for i in range(N): if unused >> i & 1: l.append(i) if len(l) < 3: return [], False for C in combinations(l, 3): C = list(C) a, b, c = K[C[0]], K[C[1]], K[C[2]] if a == b or b == c or c == a: continue if not (b == max(a, b, c) or b == min(a, b, c)): continue unext = unused for i in range(3): unext &= ~(1 << C[i]) ans, can = solve(unext) if can == False: return C, True return [], False ans, can = solve((1 << N) - 1) if can: print(*ans) else: print(-1)