#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int n;
int d[maxn], cnt[maxn];
vector<int> vec, can_rev;
void read_input() {
  cin >> n;
  ++cnt[0];
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    ++cnt[d[i]];
  }
}
int bit(int k, int x) { return (x >> k & 1); }
int min_gap(vector<int>& v) {
  sort(v.begin(), v.end());
  int res = maxn;
  for (int i = 0; i < (int)v.size() - 1; ++i) res = min(res, v[i + 1] - v[i]);
  return res;
}
void solve() {
  for (int i = 0; i <= 12; ++i)
    if (cnt[i] >= 3 || ((i == 0 || i == 12) && cnt[i] >= 2)) {
      cout << "0\n";
      return;
    }
  for (int i = 1; i < 12; ++i) {
    if (cnt[i] == 2) {
      vec.push_back(i);
      vec.push_back(24 - i);
    } else if (cnt[i] == 1)
      can_rev.push_back(i);
  }
  if (cnt[12] > 0) vec.push_back(12);
  vec.push_back(0);
  int ans = 0;
  for (int mask = 0; mask < (1 << (int)can_rev.size()); ++mask) {
    vector<int> all = vec;
    for (int i = 0; i < (int)can_rev.size(); ++i)
      all.push_back(bit(i, mask) ? 24 - can_rev[i] : can_rev[i]);
    ans = max(ans, min_gap(all));
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  read_input();
  solve();
}
