#include using namespace std; typedef long long ll; const ll INF = 1e18; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define int long long using pint = pair; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; signed main() { int n; cin >> n; int t[n]; rep (i, 0, n) cin >> t[i]; set st; rep (i, 0, n) { bool chk = 1; rep (j, 0, n) { int s = (t[j] - t[i]) % 12; if (s < 0) s += 12; if (s == 0 || s == 2 || s == 4 || s == 5 || s == 7 || s == 9 || s == 11) { continue; } else { chk = 0; break; } } if (chk) st.insert (t[i]); } if (st.size() == 1) { for (auto i : st) cout << i << "\n"; } else { cout << "-1\n"; } }