#include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { int n; cin >> n; int p[7] = { 0,2,4,5,7,9,11 }; int s[12] = {}; for (int i = 0; i < 7; i++) { s[p[i]]++; } int q[12] = {}; for (int i = 0; i < n; i++) { int t; cin >> t; q[t] = 1; } int r = -1; for (int j = 0; j < 12; j++) { int b = 1; for (int i = 0; i < 12; i++) { if (q[(i + j) % 12] && !s[i]) b = 0; } if (b) { if (r >= 0) { cout << -1 << endl; exit(0); } r = j; } } cout << r << endl; return 0; }