#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int mindiff(vector<int>& a) {
  sort(a.begin(), a.end());
  int ans = 100;
  int N = a.size();
  for (int i = 0; i < N; ++i) {
    chmin(ans, abs(a[(i + 1) % N] - a[i]));
  }
  return ans;
}
int main() {
  int N;
  cin >> N;
  vector<int> d(N + 1, 0);
  map<int, int> mp;
  for (int i = 0; i < N; ++i) {
    cin >> d[i + 1];
    ++mp[d[i + 1]];
  }
  ++mp[0];
  if (mp[0] >= 2 || mp[12] >= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= 11; ++i)
    if (mp[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  int res = 0;
  bool flg12 = false;
  if (mp[12] == 1) flg12 = true;
  vector<int> ans;
  for (int bit = 0; bit < 1 << 11; ++bit) {
    ans.resize(1, 0);
    if (flg12) ans.push_back(12);
    for (int i = 0; i < 11; ++i) {
      if (mp[i + 1] == 0)
        continue;
      else if (mp[i + 1] == 1 && (bit & 1 << i) != 0)
        ans.push_back(i + 1);
      else if (mp[i + 1] == 1 && (bit & 1 << i) == 0)
        ans.push_back(24 - i - 1);
      else if (mp[i + 1] == 2) {
        ans.push_back(i + 1);
        ans.push_back(24 - i - 1);
      }
    }
    chmax(res, mindiff(ans));
  }
  cout << res << endl;
}
