#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
struct edge {
  long long to, cost;
};
long long t[13];
long long w[25];
signed main() {
  long long n;
  cin >> n;
  t[0]++;
  for (long long i = 0; i < n; i++) {
    long long d;
    cin >> d;
    t[d]++;
  }
  vector<long long> V;
  for (long long i = 0; i < 13; i++) {
    if (i) {
      if (t[i] == 2) {
        w[i]++;
        w[24 - i]++;
      } else if (t[i] > 2) {
        cout << 0 << endl;
        return 0;
      } else if (t[i] == 1) {
        V.push_back(i);
      }
    } else {
      if (t[i] == 1) {
        w[i]++;
      } else {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  long long res = 0;
  for (long long i = 0; i < (1 << V.size()); i++) {
    long long nw[24];
    for (long long j = 0; j < 24; j++) nw[j] = w[j];
    for (long long j = 0; j < V.size(); j++) {
      if (i & (1 << j))
        nw[j] = 1;
      else
        nw[24 - j] = 1;
    }
    vector<long long> ans;
    for (long long j = 0; j < 24; j++) {
      if (nw[j]) {
        ans.push_back(j);
        ans.push_back(24 + j);
      }
    }
    sort(ans.begin(), ans.end());
    long long k = 24;
    for (long long j = 0; j < ans.size() - 1; j++) {
      k = min(k, ans[j + 1] - ans[j]);
    }
    res = max(res, k);
  }
  cout << res << endl;
}
