#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair P; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; int dp[1<<12]; int n; int a[12]; inline bool check(int i, int j, int k) { if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) return false; int tmp[3] = {a[i], a[j], a[k]}; sort(tmp, tmp + 3); if (a[i] == tmp[1] || a[k] == tmp[1]) return true; return false; } int dfs(int s) { if (~dp[s]) return dp[s]; int res = 0; REP(i, n) if (!(s >> i & 1)) { FOR(j, i + 1, n) if (!(s >> j & 1)) { FOR(k, j + 1, n) if (!(s >> k & 1)) { if (!check(i, j, k)) continue; if (!dfs(s | 1<> n; REP(i, n) cin >> a[i]; memset(dp, -1, sizeof(dp)); P ans(INF, pii(0, 0)); REP(i, n) FOR(j, i + 1, n) FOR(k, j + 1, n) { if (!check(i, j, k)) continue; if (!dfs(1<