#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
int h = 0, w, n = 0, m, s, ans = 1000, a[100] = {}, c[24] = {}, b[12] = {},
    sum = 0, pos[2][2] = {}, dp[1000][1000] = {};
int flag = 0;
string str;
int main() {
  cin >> n;
  a[0]++;
  int cs = 0, num = 0;
  for (int i = 0; i < n; i++) {
    int aa;
    cin >> aa;
    ans = min(aa, ans);
    if (a[aa] == 0) {
      a[aa]++;
    } else if (a[24 - aa] == 1 || aa == 0)
      ans = 0;
    else {
      a[24 - aa]++;
      c[cs] = 24 - aa;
      cs++;
      c[cs] = aa;
      cs++;
    }
    if (aa == 12) {
      c[cs] = 12;
      cs++;
    }
  }
  if (ans <= 6)
    cout << ans << endl;
  else {
    ans = 0;
    for (int i = 1; i < 12; i++) {
      if (a[i] == 1 && a[24 - i] == 0) {
        b[num] = i;
        num++;
      }
    }
    for (int i = 0; i < (2 << num); i++) {
      int cc[24] = {};
      for (int j = 0; j < cs; j++) cc[j] = c[j];
      for (int j = 0; j < num; j++) {
        bool aa = (i % (1 << (j + 1))) / (1 << (j));
        if (aa)
          cc[cs + j] = b[j];
        else
          cc[cs + j] = 24 - b[j];
      }
      sort(cc, cc + cs + num);
      int AAA = 100;
      for (int j = 0; j < cs + num - 1; j++) AAA = min(AAA, cc[j + 1] - cc[j]);
      ans = max(ans, AAA);
    }
    cout << ans << endl;
  }
  return 0;
}
