#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) template inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } typedef long long ll; // bit でとったとってないを表現 // その状態をsとする int N; int K[12]; bool reg[1<<12]; tuple dp[1<<12]; // 1手目 const int inf = 1e9; bool kadomatsu(int x, int y, int z) { if(x == y || y == z || z == x) return false; if(x > y && y < z) return true; if(x < y && y > z) return true; return false; } tuple f(int s) { if(reg[s]) return dp[s]; tuple ret {inf, inf, inf}; FOR(i,0,N) FOR(j,i+1,N) FOR(k,j+1,N) { if (s & (1 << i)) continue; // 取られていたらcontinue if (s & (1 << j)) continue; if (s & (1 << k)) continue; if (kadomatsu(K[i], K[j], K[k])) { auto val = f(s | (1 << i) | (1 << j) | (1 << k)); if(get<0>(val) == inf){ chmin(ret, make_tuple(i, j, k)); } } } reg[s] = true; dp[s] = ret; return ret; } int main(){ cin >> N; FOR(i,0,N) cin >> K[i]; FOR(i,0,1<<12) reg[i] = false; auto ans = f(0); if(get<0>(ans) == inf){ cout << -1 << endl; } else { int x, y, z; tie(x, y, z) = ans; printf("%d %d %d\n", x, y, z); } return 0; }