#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <class T1, class T2>
void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using Pi = pair<long long, long long>;
using Ti = tuple<long long, long long, long long>;
using vint = vector<long long>;
const long long inf = 1LL << 55;
const long long mod = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  long long n;
  cin >> n;
  vint d(n);
  long long ans = 0;
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> d[i];
  d.push_back(0);
  n++;
  sort((d).begin(), (d).end());
  for (long long i = (long long)(0); i < (long long)(n + 1); i++) {
    long long s = inf;
    for (long long j = (long long)(0); j < (long long)(n); j++)
      for (long long k = (long long)(j + 1); k < (long long)(n); k++) {
        long long a = j < i ? d[j] : 24 - d[j];
        long long b = k < i ? d[k] : 24 - d[k];
        chmin(s, min(abs(a - b), 24 - abs(a - b)));
      }
    chmax(ans, s);
  }
  cout << ans << endl;
  return 0;
}
