#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
long long solve() {
  long long ret = INF;
  long long N;
  cin >> N;
  vector<long long> D(N);
  for (auto& in : D) cin >> in;
  vector<long long> t;
  t.push_back(0);
  for (int i = 0; i < N; i++) {
    ret = min(ret, D[i]);
    long long t1 = D[i], t2 = 24 - D[i];
    long long dif1 = INF, dif2 = INF;
    for (auto T : t) {
      dif1 = min(dif1, min(abs(t1 - T), abs(24 + t1 - T)));
      dif2 = min(dif2, min(abs(t2 - T), abs(24 + t2 - T)));
    }
    ret = min(ret, max(dif1, dif2));
    if (dif1 > dif2) {
      t.push_back(t1);
    } else {
      t.push_back(t2);
    }
  }
  return ret;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << solve() << endl;
  return 0;
}
