#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int infi = 2147483600;
const long long infl = 1e17;
int calc(set<int> now) {
  int res = infi;
  for (auto x : now) {
    for (auto y : now) {
      if (x == y) continue;
      int z = abs(x - y);
      res = min(res, min(z, 24 - z));
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (long long i = 0; i < (long long)n; i++) cin >> d[i];
  vector<int> cnt(13, 0);
  for (long long i = 0; i < (long long)n; i++) {
    if (d[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    cnt[d[i]]++;
  }
  set<int> kakutei;
  vector<pair<int, int> > choice;
  for (long long i = 0; i < (long long)13; i++) {
    if (cnt[i] > 2) {
      cout << 0 << endl;
      return 0;
    } else if (cnt[i] == 2) {
      kakutei.insert(i);
      kakutei.insert(24 - i);
    } else if (cnt[i] == 1) {
      choice.push_back(make_pair(i, 24 - i));
    }
  }
  int ans = 0;
  for (long long s = 0; s < (long long)1 << (choice.size()); s++) {
    set<int> now(kakutei);
    for (long long i = 0; i < (long long)choice.size(); i++) {
      if ((s >> i) & 1) {
        now.insert(choice[i].first);
      } else {
        now.insert(choice[i].second);
      }
    }
    ans = max(ans, calc(now));
  }
  cout << ans << endl;
}
