#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, D[51];

int main(void) {
  cin >> N;
  D[0] = 0;
  REP(i, 1, N + 1) cin >> D[i];
  N++;

  if(N > 24) {
    cout << 0 << endl;
  } else {
    vector<ll> d(N);
    vector<ll> cnt(25);
    ll ans = 0;
    REP(i, 0, 1LL << N) {
      bool f = true;
      REP(j, 0, 25) cnt[j] = 0;
      REP(j, 0, N) {
        d[j] = ((i & (1LL << j)) == 0 ? D[j] : 24 - D[j]);
        if(cnt[d[j]] > 0) {
          f = false;
          break;
        }
        cnt[d[j]]++;
      }
      if(!f) continue;

      sort(d.begin(), d.end());

      ll s = (1LL << 60);
      REP(j, 0, N) s = min(s, min(abs(d[(j + 1) % N] - d[j]), 24 - abs(d[(j + 1) % N] - d[j])));

      ans = max(ans, s);
    }
    cout << ans << endl;
  }
}
