#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long N;
  cin >> N;
  map<long long, long long> cnt;
  cnt[0] = 1;
  for (long long i = 0, i_len = (N); i < i_len; ++i) {
    long long d;
    cin >> d;
    cnt[d]++;
    cnt[24 - d]++;
  }
  if (cnt[0] > 1) {
    cout << 0 << endl;
    return 0;
  }
  bool useNext = true;
  vector<long long> r;
  for (long long i = (0), i_len = (23); i <= i_len; ++i) {
    if (cnt.count(i) == 0) continue;
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
    if (cnt[i] == 2 || i == 12) {
      r.push_back(i);
    }
    if (cnt[i] == 1) {
      if (useNext) {
        r.push_back(i);
        useNext = false;
      } else {
        useNext = true;
      }
    }
  }
  long long rans = 1001001001001001001ll;
  for (long long i = 0, i_len = (r.size() - 1); i < i_len; ++i) {
    rans = min(rans, abs(r[i + 1] - r[i]));
  }
  useNext = true;
  vector<long long> l;
  for (long long i = (24); i >= (0); --i) {
    if (cnt.count(i) == 0) continue;
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
    if (cnt[i] == 2 || i == 12) {
      l.push_back(i);
    }
    if (cnt[i] == 1) {
      if (useNext) {
        l.push_back(i);
        useNext = false;
      } else {
        useNext = true;
      }
    }
  }
  long long lans = 1001001001001001001ll;
  for (long long i = 0, i_len = (l.size() - 1); i < i_len; ++i) {
    lans = min(lans, abs(l[i + 1] - l[i]));
  }
  long long ans = max(lans, rans);
  cout << ans << endl;
  return 0;
}
