#include <bits/stdc++.h>
using namespace std;
template <class T, class S>
void cmin(T &a, const S &b) {
  if (a > b) a = b;
}
template <class T, class S>
void cmax(T &a, const S &b) {
  if (a < b) a = b;
}
signed main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (auto &e : v) cin >> e;
  array<short, 13> cnt = {0};
  cnt[0]++;
  for (auto e : v) cnt[e]++;
  for (auto e : cnt)
    if (e >= 3) return puts("0") * 0;
  if (cnt[0] >= 2 or cnt[12] >= 2) return puts("0") * 0;
  int ans = -(sizeof(int) == 4 ? (int)1e9 : (int)1e18);
  for (int bit = 0; bit < (1LL << 12); ++bit) {
    vector<int> pos(25, 0LL);
    pos[0] = cnt[0];
    pos[12] = cnt[12];
    int tans = (sizeof(int) == 4 ? (int)1e9 : (int)1e18);
    for (int i = 1; i < 12; ++i) {
      if ((bit & (1LL << (i))) and cnt[i] > 0) {
        pos[i] = 1;
        pos[24 - i] = (cnt[i] - pos[i]);
      } else {
        pos[i] = 0;
        pos[24 - i] = (cnt[i] - pos[i]);
      }
    }
    for (int i = 0; i < pos.size(); ++i) {
      for (int j = 0; j < pos.size(); ++j) {
        if (i != j and pos[i] == 1 and pos[j] == 1)
          cmin(tans, min(abs(i - j), 24 - abs(i - j)));
      }
    }
    if (tans == (sizeof(int) == 4 ? (int)1e9 : (int)1e18)) continue;
    cmax(ans, tans);
  }
  cout << ans << endl;
}
