#include <bits/stdc++.h>
using namespace std;
int num[15];
int main() {
  int n;
  cin >> n;
  n++;
  vector<int> v;
  v.push_back(0);
  for (int(i) = (0); (i) < (n); ++i) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    num[tmp]++;
  }
  if (n > 24 || num[0] > 0 || num[12] > 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= 11; i++) {
    if (num[i] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (num[1] > 0 || (num[12] > 0 && num[11] > 0)) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 1; i >= 11; i++) {
    if (num[i] = 2 && (num[i + 1] > 0 || num[i - 1] > 0)) {
      cout << 1 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (int now = 0; now < (1 << n); now++) {
    vector<int> vv;
    for (int(i) = (0); (i) < (n); ++i) {
      if (now & (1 << i)) {
        vv.push_back(24 - v[i]);
      } else {
        vv.push_back(v[i]);
      }
    }
    int ret = 100;
    for (int(i) = (0); (i) < (n); ++i) {
      for (int(j) = (0); (j) < (n); ++j) {
        if (i == j) continue;
        int tmp = abs(vv[i] - vv[j]);
        ret = min(ret, min(tmp, 24 - tmp));
      }
    }
    ans = max(ans, ret);
  }
  cout << ans << endl;
  return 0;
}
