/** * @FileName a.cpp * @Author kanpurin * @Created 2020.07.10 21:35:02 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n; cin >> n; vector< int > t(n); for (int i = 0; i < n; i++) { cin >> t[i]; } int ans = -1; for (int i = 0; i < 12; i++) { bool ok = true; for (int j = 0; j < n; j++) { if (i % 12 == t[j] || (i + 2) % 12 == t[j] || (i + 4) % 12 == t[j] || (i + 5) % 12 == t[j] || (i + 7) % 12 == t[j] || (i + 9) % 12 == t[j] || (i + 11) % 12 == t[j]) { } else { ok = false; break; } } if (ok && ans != -1) { cout << -1 << endl; return 0; } else if (ok) { ans = i; } } cout << ans << endl; return 0; }