#include <bits/stdc++.h>
using namespace std;
bool ex[24];
int cnt[13];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> v;
  for (int i = (0); i < (N); ++i) {
    int d;
    cin >> d;
    cnt[d]++;
  }
  if (cnt[0]) ex[0] = true;
  if (cnt[12]) ex[12] = true;
  for (int i = (1); i < (12); ++i) {
    if (cnt[i] == 1) {
      v.push_back(i);
    }
    if (cnt[i] >= 2) {
      ex[i] = ex[24 - i] = true;
    }
  }
  int ans = 0;
  int n = v.size();
  for (int i = (0); i < (1 << n); ++i) {
    bool ex2[24];
    for (int j = (0); j < (24); ++j) ex2[j] = ex[j];
    for (int j = (0); j < (n); ++j) {
      if (i & (1 << j)) {
        ex2[v[j]] = true;
      } else {
        ex2[24 - v[j]] = true;
      }
    }
    int mn = 1e9;
    for (int i = (0); i < (24); ++i) {
      for (int j = (i + 1); j < (24); ++j) {
        if (i == j) continue;
        if (ex2[i] && ex2[j]) {
          mn = min(mn, abs(j - i));
          mn = min(mn, 24 - abs(j - i));
        }
      }
    }
    ans = max(ans, mn);
  }
  cout << ans << endl;
}
