#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector K(N); rep(i,N) cin >> K[i]; vector> G(1 << N); enum {WIN, LOSE}; vector dp(1 << N, -1); rep(S,1< id; rep(i,N) if(S & (1 << i)) id.push_back(i); int n = id.size(); int LOSE_CNT = 0; rep(k,n)rep(j,k)rep(i,j) { int a = id[i], b = id[j], c = id[k]; auto [mi, ma] = minmax({K[a], K[b], K[c]}); if(K[a] != K[b] && K[b] != K[c] && K[c] != K[a] && (mi == K[b] || ma == K[b])) { if(dp[S - (1 << a) - (1 << b) - (1 << c)] == LOSE) LOSE_CNT++; } } dp[S] = (LOSE_CNT >= 1 ? WIN : LOSE); } } if(dp[(1 << N) - 1] == WIN) { tuple ans = {1e9, 1e9, 1e9}; rep(c,N)rep(b,c)rep(a,b) { auto [mi, ma] = minmax({K[a], K[b], K[c]}); if(K[a] != K[b] && K[b] != K[c] && K[c] != K[a] && (mi == K[b] || ma == K[b])) { if(dp[((1 << N) - 1) - (1 << a) - (1 << b) - (1 << c)] == LOSE) { ans = min(ans, tuple{a, b, c}); } } } auto [a, b, c] = ans; cout << a << " " << b << " " << c << endl; } else { cout << -1 << endl; } }