#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const double eps = 1e-10;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int d[13] = {};
  cin >> N;
  for (int i = 0; i < (N); i++) {
    int D;
    cin >> D;
    if (D == 0) {
      cout << 0 << endl;
      return 0;
    }
    d[D]++;
    if ((D == 12 && d[D] > 1) || d[D] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  int res = 0;
  int D[51] = {};
  int ok = 1;
  vector<int> a;
  for (int i = 0; i < (13); i++) {
    if (d[i] == 2) {
      D[ok] = i;
      D[ok + 1] = 24 - i;
      ok += 2;
    } else if (d[i] == 1) {
      a.push_back(i);
    }
  }
  for (int i = 0; i < (1 << a.size()); i++) {
    int DD[51] = {};
    for (int j = 0; j < (ok); j++) {
      DD[j] = D[j];
    }
    int ret = (int)1e9;
    for (int j = 0; j < (a.size()); j++) {
      DD[j + ok] = (i >> j) & 1 ? a[j] : 24 - a[j];
    }
    sort(DD, DD + N + 1);
    for (int j = 0; j < (N + 1); j++) {
      ret = min(ret, abs(DD[j] - DD[(j + 1) % (N + 1)]));
    }
    res = max(ret, res);
  }
  cout << res << endl;
}
