#include int f(int n) { n = (n % 12 + 12) % 12; if (n == 0 || n == 2 || n == 4 || n == 5 || n == 7 || n == 9 || n == 11) return 0; else return 1; } int main() { int n; scanf("%d", &n); int i, j; int t[16]; for (i = 0; i < n; i++) scanf("%d", &t[i]); int cnt = 0, v; for (i = 0; i < 12; i++) { v = 0; for (j = 0; j < n; j++) v += f(t[j] - i); if (v == 0) cnt++; } if (cnt == 1) { for (i = 0; i < 12; i++) { v = 0; for (j = 0; j < n; j++) v += f(t[j] - i); if (v == 0) printf("%d\n", i); } } else printf("-1\n"); return 0; }