#include #include using namespace std; int tyo[7] = {0,2,4,5,7,9,11}; int main(){ int n;cin>>n; set A; for(int i = 0; n > i; i++){ int x;cin>>x; A.insert(x); } int ans = -1; for(int i = 0; 12 > i; i++){ int z = 0; for(int j = 0; 7 > j; j++){ if(A.count((i+tyo[j])%12))z++; } if(z == A.size()){ if(ans == -1){ ans = i; }else{ cout << -1 << endl; return 0; } } } cout << ans << endl; }