#include <bits/stdc++.h>
using namespace std;
void solve() {
  int N;
  cin >> N;
  vector<int> s(12);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    if (d) {
      s[d - 1]++;
    } else {
      cout << 0 << endl;
      return;
    }
  }
  for (int bit = 0; bit < 1 << 12; bit++) {
    vector<int> v;
    v.push_back(0);
    for (int i = 0; i < 12; i++) {
      if (!s[i]) continue;
      v.push_back((bit >> i & 1) ? i + 1 : 23 - i);
      if (s[i] > 1) v.push_back((bit >> i & 1) ? 23 - i : i + 1);
    }
    int n = v.size(), res = 12;
    for (int i = 0; i < n - 1; i++)
      for (int j = i + 1; j < n; j++) {
        int diff = abs(v[j] - v[i]);
        res = min(res, min(24 - diff, diff));
      }
    ans = max(ans, res);
  }
  cout << ans << endl;
}
int main(void) {
  solve();
  return 0;
}
