#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int h[10] = { 0,2,4,5,7,9,11 }; int main() { int n; int t[20]; cin >> n; for (int i = 0; i < n; i++) { cin >> t[i]; } int ans; bool b = true, bo = false; for (int i = 0; i < 12; i++) { vector vec; for (int j = 0; j < 7; j++) { vec.emplace_back((i + h[j]) % 12); } sort(vec.begin(), vec.end()); b = true; for (int j = 0; j < n; j++) { if (!binary_search(vec.begin(), vec.end(), t[j])) { b = false; } } if (b) { if (bo) { cout << "-1" << endl; return 0; } else { bo = true; ans = i; } } } if (bo) { cout << ans << endl; } else { cout << "-1" << endl; } cout << endl; return 0; }