#include <bits/stdc++.h>
using namespace std;
vector<int> v(1000);
priority_queue<pair<int, pair<int, int> > > Q;
int N;
set<pair<int, int> > SET;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  N++;
  int D[N];
  D[0] = 0;
  for (int i = (1); i < (N); ++i) cin >> D[i];
  for (int i = (0); i < (N); ++i) {
    v[i] = D[i];
    v[i + N] = 24 - D[i];
  }
  for (int i = (0); i < (2 * N); ++i) {
    for (int j = (i + 1); j < (2 * N); ++j) {
      if (j == i + N) continue;
      Q.push(pair<int, pair<int, int> >(
          min(24 - abs(v[i] - v[j]), abs(v[i] - v[j])), pair<int, int>(i, j)));
    }
  }
  int cnt = 0;
  while (!Q.empty()) {
    pair<int, pair<int, int> > pp = Q.top();
    Q.pop();
    int d = pp.first;
    int u = pp.second.first;
    int v = pp.second.second;
    bool plus = false;
    int uu = u < N ? u + N : u - N;
    int vv = v < N ? v + N : v - N;
    if (SET.count(pair<int, int>(min(uu, v), max(uu, v))) ||
        SET.count(pair<int, int>(min(u, vv), max(u, vv))) ||
        SET.count(pair<int, int>(min(uu, vv), max(uu, vv))))
      plus = false;
    else
      plus = true;
    SET.insert(pair<int, int>(min(u, v), max(u, v)));
    cnt += plus;
    if (2 * cnt == N * (N - 1)) {
      cout << d << endl;
      return 0;
    }
  }
}
