#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);
  for(int i=0;i<n;++i) {
    cin >> d[i];
    d[i] = min(d[i], 24 - d[i]);
  }
  sort(d.begin(), d.end());
  // printv(d);
  vector<int> t(n+1);
  t[n] = 0;
  bool now = 0;
  for(int i=0;i<n;++i) {
    if(now) {
      t[i] = d[i];
    } else {
      t[i] = 24 - d[i];
    }
    now = !now;
  }
  
  sort(t.begin(), t.end());
  
  // printv(t1);
  // printv(t2);

  int mi = INF;

  for(int i=0;i<n+1;++i) {
    for(int j=i+1;j<n+1;++j) {
      mi = min(mi, min(abs(t[i] - t[j]), 24 - abs(t[i] - t[j])));
    }
  }

  cout << mi << endl;

}
