#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int cnt[13];
bool hoge[13];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec;
  cnt[0]++;
  for (int i = 0; i < (int)(n); ++i) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  if (cnt[0] >= 2 || cnt[12] >= 2) {
    cout << "0\n";
    return 0;
  }
  for (int i = 0; i < (int)(13); ++i) {
    if (cnt[i] >= 3) {
      cout << "0\n";
      return 0;
    } else if (cnt[i] == 2) {
      vec.push_back(i);
      hoge[i] = true;
    } else if (cnt[i] == 1) {
      vec.push_back(i);
    }
  }
  n = (int)(vec).size();
  int ans = 0;
  for (int i = 0; i < (int)((1 << n)); ++i) {
    int mn = 1000000005;
    vector<int> val;
    for (int j = 0; j < (int)(n); ++j) {
      if (hoge[j]) {
        val.push_back(vec[j]), val.push_back((24 - vec[j]) % 24);
      } else {
        if (i & (1 << j)) {
          val.push_back((24 - vec[j]) % 24);
        } else {
          val.push_back(vec[j]);
        }
      }
    }
    sort((val).begin(), (val).end());
    for (int j = 0; j < (int)((int)(val).size() - 1); ++j) {
      mn = min(mn, val[j + 1] - val[j]);
    }
    ans = max(ans, mn);
  }
  cout << ans << "\n";
  return 0;
}
