#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) templateostream& operator<<(ostream& os,const pair&a){return os<<"("<void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<void chmin(T&a,const T&b){if(a>b)a=b;} templatevoid chmax(T&a,const T&b){if(a T; REP(i, N) T.insert(nextLong()); vector ans; for (int D = 0; D < 12; D++) { bool ok = true; set S; for (int i : {0, 2, 4, 5, 7, 9, 11}) { int d = (D + i) % 12; S.insert(d); } for (int t : T) { if (S.count(t) == 0) ok = false; } if (ok) ans.push_back(D); } if (ans.size() == 1) { cout << ans[0] << endl; } else { cout << -1 << endl; } return 0; } int main() { #ifdef LOCAL for (;!cin.eof();cin>>ws) #endif main2(); return 0; }