#include <bits/stdc++.h>
using namespace std;
const int maxn = 24;
int mark[maxn];
int mk[maxn];
int main() {
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    mark[x]++;
  }
  mark[0]++;
  for (int e = 0; e < 13; e++) mark[e] = min(mark[e], 2);
  vector<int> val, good;
  for (int e = 0; e < 13; e++) {
    if (mark[e] >= 2)
      good.push_back(e), good.push_back(24 - e);
    else if (mark[e] == 1)
      val.push_back(e);
    else if (mark[e] > 2) {
      return !printf("0\n");
    }
  }
  int ans = 0;
  for (int e = -1; e < 1 << val.size(); e++) {
    memset(mk, 0, sizeof(mk));
    if (~e)
      for (int f = 0; f < val.size(); f++) {
        if (e & (1 << f))
          mk[24 - val[f]]++;
        else
          mk[val[f]]++;
      }
    for (int v : good) mk[v]++;
    int lst = -1, val = 25;
    for (int f = 0; f < maxn; f++) {
      if (mk[f]) {
        if (lst != -1) {
          int mt = f - lst;
          val = min(val, min(mt, 24 - mt));
        }
        lst = f;
      }
    }
    for (int f = 0; f < maxn; f++)
      if (mk[f] > 1) val = 0;
    int fst = -1, bst = -1;
    for (int f = 0; f < maxn && fst == -1; f++)
      if (mk[f]) fst = f;
    for (int f = 0; f < maxn; f++)
      if (mk[f]) bst = f;
    for (int f = 0; f < maxn; f++) {
      if (mk[f]) {
        int fi = f - fst;
        int se = bst - f;
        fi = min(fi, 24 - fi);
        se = min(se, 24 - se);
        if (f != fst) val = min(val, fi);
        if (f != bst) val = min(val, se);
      }
    }
    if (val == 25) val = 0;
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}
