#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;
  for (int i = (1); i < (n + 1); ++i) cin >> d[i];
  for (int i = (0); i < (n + 1); ++i) {
    for (int j = (i + 1); j < (n + 1); ++j) {
      int ab = abs(d[i] - d[j]);
      pq.push(
          pair<int, pair<int, int> >(min(ab, 24 - ab), pair<int, int>(i, j)));
      ab = abs(24 - d[i] - d[j]);
      pq.push(
          pair<int, pair<int, int> >(min(ab, 24 - ab), pair<int, int>(i, j)));
    }
  }
  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;
    cnt[x][y]++;
    if (cnt[x][y] == 2) {
      ans = tm;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
