#include <bits/stdc++.h>
using namespace std;
template <typename T>
string join(vector<T>& v) {
  stringstream s;
  for (int i = (0); i < ((int)(v).size()); i++) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& v) {
  fill((T*)array, (T*)(array + N), v);
}
long long gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  for (; a > 0; b %= a, swap(a, b))
    ;
  return b;
}
int modpow(long long a, long long n, int m) {
  if (a == 0) return a;
  long long p = 1;
  for (; n > 0; n /= 2, a = a * a % m)
    if (n & 1) p = p * a % m;
  return (int)p;
}
void dout(double d) { printf("%.12f\n", d); }
const int iinf = 1e9;
const long long linf = 1e18;
const int mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, d[50];
int _tm(int a) {
  if (a < 0) a += 24;
  return min(a, 24 - a);
}
bool check(int a) {
  vector<pair<int, int> > G[50][2];
  bool z[50][2], zz[50][2];
  for (int i = (0); i < (n - 1); i++)
    for (int j = (i + 1); j < (n); j++) {
      if (_tm(d[i] - d[j]) < a) {
        G[i][0].push_back(make_pair(j, 1));
        G[i][1].push_back(make_pair(j, 0));
        G[j][0].push_back(make_pair(i, 1));
        G[j][1].push_back(make_pair(i, 0));
      }
      if (_tm(d[i] + d[j]) < a) {
        G[i][0].push_back(make_pair(j, 0));
        G[i][1].push_back(make_pair(j, 1));
        G[j][0].push_back(make_pair(i, 0));
        G[j][1].push_back(make_pair(i, 1));
      }
    }
  queue<pair<int, int> > q;
  for (int i = (0); i < (n); i++) {
    if (z[i][0]) continue;
    q.push(make_pair(i, 0));
    z[i][0] = true;
    Fill(zz, false);
    zz[i][0] = true;
    while ((int)(q).size()) {
      pair<int, int> t = q.front();
      q.pop();
      for (__typeof((G[t.first][t.second]).begin()) itr =
               (G[t.first][t.second]).begin();
           itr != (G[t.first][t.second]).end(); itr++) {
        if (zz[itr->first][1 - itr->second]) return false;
        if (zz[itr->first][itr->second]) continue;
        zz[itr->first][itr->second] = true;
        z[itr->first][itr->second] = true;
        q.push(*itr);
      }
    }
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  if (n > 23) {
    cout << 0 << endl;
    return 0;
  }
  int minv = iinf;
  for (int i = (0); i < (n); i++) {
    cin >> d[i];
    minv = min(minv, d[i]);
  }
  int l = 0, r = minv + 1, mid;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}
