#include #include #include #include #include #include #include using namespace std; int N; int K[12]; int dp[1 << 12]; bool kadomatsu(int a, int b, int c) { if(a == b || b == c || c == a) return false; return b < a && b < c || b > a && b > c; } vector comp(vector m1, vector m2) { for(int i = 0; i < 3; i++) { if(m1[i] < m2[i]) return m1; } return m2; } int f(int rem, vector& move) { if(dp[rem] != 0) return dp[rem]; dp[rem] = -1; for(int i = 0; i < N; i++) { if(rem >> i & 1) continue; for(int j = i + 1; j < N; j++) { if(rem >> j & 1) continue; for(int k = j + 1; k < N; k++) { if(rem >> k & 1) continue; if(kadomatsu(K[i], K[j], K[k])) { int nr = rem ^ (1 << i) ^ (1 << j) ^ (1 << k); vector m(3, 100); int res = -f(nr, m); if(res == 1) { vector mm({ i, j, k }); move = comp(move, mm); dp[rem] = 1; } } } } } return dp[rem]; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; for(int i = 0; i < N; i++) { cin >> K[i]; } vector m(3, 100); if(f(0, m) == 1) { for(int i = 0; i < 3; i++) { cout << m[i] << " "; } cout << endl; } else { cout << -1 << endl; } }