#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
  edge(int t, int c) : to(t), cost(c) {}
};
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int ddx[] = {1, 1, 1, 0, -1, -1, -1, 0}, ddy[] = {1, 0, -1, -1, -1, 0, 1, 1};
int n;
int d[51], cnt[51][51];
vector<pair<int, int> > v;
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    pq;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  v.push_back(pair<int, int>(0, 0));
  v.push_back(pair<int, int>(24, 0));
  for (int i = (0); i < (n); ++i) {
    cin >> d[i];
    v.push_back(pair<int, int>(d[i], i + 1));
    v.push_back(pair<int, int>(24 - d[i], i + 1));
  }
  for (int i = (0); i < (v.size()); ++i) {
    for (int j = (0); j < (v.size()); ++j) {
      if (v[i].second == v[j].second) continue;
      int dif = abs(v[i].first - v[j].first);
      int x = v[i].second, y = v[j].second;
      pq.push(
          pair<int, pair<int, int> >(min(dif, 24 - dif), pair<int, int>(x, y)));
      if (x > y) swap(x, y);
      cnt[x][y]++;
    }
  }
  int ans;
  while (!pq.empty()) {
    pair<int, pair<int, int> > p = pq.top();
    pq.pop();
    int tm = p.first, x = p.second.first, y = p.second.second;
    if (x > y) swap(x, y);
    cnt[x][y]--;
    if (cnt[x][y] == 0) {
      ans = tm;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
