#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e12;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  n++;
  vector<long long> d(n);
  d[0] = 0;
  for (long long i = 1; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  vector<vector<long long> > e(2, vector<long long>(n));
  for (long long i = 1; i < n; i++) {
    e[0][i] = d[i];
    e[1][i] = 24 - d[i];
  }
  e[0][0] = 0;
  e[1][0] = 0;
  long long ans = 0;
  for (long long i = 1; i < 25; i++) {
    long long id = 0, now = 0;
    bool f[55] = {}, g = true;
    f[0] = true;
    for (long long j = 1; j < n; j++) {
      if (e[0][j] >= now + i) {
        now = e[0][j];
        f[j] = true;
      }
    }
    for (long long j = n - 1; j >= 0; j--) {
      if (f[j])
        continue;
      else {
        if (e[1][j] >= now + i) {
          now = e[1][j];
          f[j] = true;
        } else {
          g = false;
        }
      }
    }
    long long cnt = 0;
    for (long long j = 0; j < n; j++)
      if (f[j]) cnt++;
    if (cnt != n) g = false;
    if (g) ans = i;
  }
  ans = min(ans, 24 - ans);
  if (n == 2) ans = d[1];
  cout << ans << endl;
}
