#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, D[N];
int F[N];
int cnt[N];
int mask;
int shit;
int calc() {
  int ans = 24;
  vector<int> showkat;
  for (int i = 0; i < 24; ++i)
    if (mask & (1 << i)) showkat.push_back(i);
  for (int i = 1; i < showkat.size(); ++i)
    ans = min(ans, showkat[i] - showkat[i - 1]);
  if (showkat.size() == 1) return 0;
  ans = min(ans, 24 - showkat.back() + showkat[0]);
  return ans;
}
void subha(int ans) {
  cout << ans << endl;
  exit(0);
}
int main() {
  cin >> n;
  n += 1;
  cnt[0] += 1;
  for (int i = 2; i <= n; ++i) {
    cin >> D[i];
    cnt[D[i]] += 1;
  }
  vector<int> F;
  for (int i = 0; i <= 12; ++i) {
    if (cnt[i] > 2) subha(0);
    if (cnt[i] == 2) {
      mask |= 1 << i;
      mask |= 1 << (24 - i);
    }
    if (cnt[i] == 1) F.push_back(i);
  }
  int gap = 0;
  n = F.size();
  for (int naz = 0; naz < (1 << n); ++naz) {
    for (int i = 0; i < n; ++i) {
      if (naz & (1 << i))
        mask ^= 1 << F[i];
      else
        mask ^= 1 << (24 - F[i]);
    }
    gap = max(gap, calc());
    for (int i = 0; i < n; ++i) {
      if (naz & (1 << i))
        mask ^= 1 << F[i];
      else
        mask ^= 1 << (24 - F[i]);
    }
  }
  cout << gap << endl;
  return 0;
}
