#include <bits/stdc++.h>
using namespace std;
int dif(vector<int> v) {
  int l = ((int)(v).size());
  sort(v.begin(), v.end());
  int d = 50;
  for (int(i) = 0; (i) < (l - 1); (i)++) d = min(d, v[i + 1] - v[i]);
  return d;
}
int main() {
  int N;
  cin >> N;
  int ct[13];
  for (int(i) = 0; (i) < (13); (i)++) ct[i] = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    int D;
    cin >> D;
    ct[D]++;
  }
  bool pos = true;
  if (ct[0] > 0) pos = false;
  for (int i = 1; i <= (int)(11); i++)
    if (ct[i] > 2) pos = false;
  if (ct[12] > 1) pos = false;
  if (!pos) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  vector<int> t;
  t.push_back(0);
  if (ct[12]) t.push_back(12);
  for (int(b) = 0; (b) < (1 << 11); (b)++) {
    vector<int> u = t;
    for (int i = 1; i <= (int)(11); i++) {
      if (ct[i] == 2) {
        u.push_back(i);
        u.push_back(24 - i);
      }
      if (ct[i] == 1) {
        if ((b >> (i - 1)) & 1)
          u.push_back(i);
        else
          u.push_back(24 - i);
      }
    }
    int k = dif(u);
    ans = max(ans, k);
  }
  cout << ans << endl;
}
