#include <bits/stdc++.h>
using namespace std;
int cnt[13], d[51];
int main() {
  int n;
  cin >> n;
  cnt[0] = 1;
  for (int i = (1); i < (n + 1); ++i) {
    cin >> d[i];
    ++cnt[d[i]];
  }
  if (cnt[0] >= 2 || cnt[12] >= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = (0); i < (13); ++i) {
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (int i = (0); i < ((1 << 11)); ++i) {
    int mn = 12;
    vector<int> v;
    for (int j = (0); j < (13); ++j) {
      if (cnt[j] == 2) {
        v.emplace_back(j);
        v.emplace_back(24 - j);
      }
      if (cnt[j] == 1) {
        if (1 & (i >> (j - 1))) {
          v.emplace_back(24 - j);
        } else
          v.emplace_back(j);
      }
    }
    for (auto it1 : v)
      for (auto it2 : v) {
        if (it1 == it2) continue;
        mn = min(abs(it1 - it2), mn);
      }
    ans = max(ans, mn);
  }
  cout << ans << endl;
  return 0;
}
