#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 29;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
int N;
int cnt[14];
int D[MAX_N];
int loop(int at, long long bit) {
  if (at == N) {
    bit = ((bit << 24) | bit);
    int res = inf;
    for (int i = int(0); i < int(24); i++) {
      if (bit & (1LL << i)) {
        for (int j = int(i + 1); j < int(48); j++) {
          if (bit & (1LL << j)) {
            res = min(res, j - i);
          }
        }
      }
    }
    return res;
  } else {
    int v1 = !(bit & (1 << ((24 - D[at]) % 24)))
                 ? loop(at + 1, bit | (1 << ((24 - D[at]) % 24)))
                 : 0;
    int v2 = !(bit & (1 << D[at])) ? loop(at + 1, bit | (1 << D[at])) : 0;
    return max(v1, v2);
  }
}
void solve() {
  cin >> N;
  for (int i = int(0); i < int(N); i++) {
    cin >> D[i];
  }
  if (N <= 12) {
    cout << loop(0, 1) << "\n";
  } else {
    cnt[0] = 1;
    for (int i = int(0); i < int(N); i++) {
      if (D[i] == 0 && D[i] == 12) {
        if (cnt[D[i]] == 1) {
          cout << 0 << "\n";
          return;
        }
      } else {
        if (cnt[D[i]] == 2) {
          cout << 0 << "\n";
          return;
        }
      }
      cnt[D[i]]++;
    }
    cout << 1 << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  srand((unsigned int)time(NULL));
  solve();
  return 0;
}
