#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
signed main() {
  long long n;
  cin >> n;
  long long u[13] = {0};
  vector<long long> d(n);
  for (long long i = 0; i < (n); i++) {
    long long v;
    cin >> v;
    d[i] = v;
    u[v]++;
    if (v == 0 || u[v] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (n > 24) {
    cout << 0 << endl;
    return 0;
  }
  d.push_back(0);
  n++;
  vector<long long> t(n);
  long long ans = 0;
  for (long long bit = 0; bit < (1LL << n); bit++) {
    long long res = LLONG_MAX / 2;
    for (long long i = 0; i < (n); i++) {
      if (bit & (1LL << i)) {
        t[i] = d[i];
      } else {
        t[i] = 24 - d[i];
      }
    }
    for (long long i = 0; i < (n); i++) {
      for (long long j = i + 1; j < n; j++) {
        res = min(res, min(abs(t[i] - t[j]), 24 - abs(t[i] - t[j])));
      }
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
