#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> d(n);
  map<int, bool> mp;
  for(int i=0;i<n;++i) {
    cin >> d[i];
    d[i] = min(d[i], 24 - d[i]);
    if(if(mp[d[i]] || d[i] == 0) {
      cout << 0 << endl;
      return 0;
    } else {
      mp[d[i]] = true;
    }
  }
  sort(d.begin(), d.end());
  // printv(d);
  vector<int> t1(n+1), t2(n+1);
  t1[n] = 0;
  bool now = 0;
  for(int i=0;i<n;++i) {
    if(now) {
      t1[i] = d[i];
    } else {
      t1[i] = 24 - d[i];
    }
    now = !now;
  }
  t2[n] = 0;
  now = 1;
  for(int i=0;i<n;++i) {
    if(now) {
      t2[i] = d[i];
    } else {
      t2[i] = 24 - d[i];
    }
    now = !now;
  }
  sort(t1.begin(), t1.end());
  sort(t2.begin(), t2.end());
  // printv(t1);
  // printv(t2);

  int mi1 = INF, mi2 = INF;
  for(int i=0;i<n;++i) {
    mi1 = min(mi1, t1[i+1] - t1[i]);
    mi2 = min(mi2, t2[i+1] - t2[i]);
  }

  cout << max(mi1, mi2) << endl;

}
