#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
int main() {
  ll n;
  cin >> n;
  set<ll> st;
  vector<ll> c(13);
  for (ll i = 0; i < n; i++) {
    ll d;
    cin >> d;
    st.insert(d);
    c[d]++;
  }
  vector<ll> v;
  for (auto &x : st) {
    if (c[x] >= 3) {
      cout << 0 << endl;
      return 0;
    }
    if (x == 0 || (x != 12 && c[x] >= 2)) v.push_back(x);
    v.push_back(x);
  }
  ll ans = 0;
  for (ll i = 0; i < 1 << v.size(); i++) {
    ll mn = INF;
    for (ll j = 0; j < v.size(); j++) {
      ll a = ((i >> j) & 1) ? v[j] : (24 - v[j]) % 24;
      for (ll k = 0; k < v.size(); k++) {
        if (j == k) continue;
        ll b = ((i >> k) & 1) ? v[k] : (24 - v[k]) % 24;
        mn = min(mn, abs(a - b));
      }
    }
    ans = max(ans, mn);
  }
  cout << ans << endl;
}
