#include using namespace std; int main() { int n; cin >> n; vector t(n); for(int i = 0; i < n; i++) cin >> t[i]; const int d[7] = {0, 2, 4, 5, 7, 9, 11}; int ans = -1; bool check; for(int i = 0; i < 12; i++) { check = true; set st; for(int j = 0; j < 7; j++) st.insert((i + d[j]) % 12); for(int j = 0; j < n; j++) { if(!st.count(t[j])) { check = false; break; } } if(check) { if(ans == -1) ans = i; else { cout << -1 << endl; return 0; } } } cout << ans << endl; return 0; }