#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using G = vector<vector<int>>;
int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
int cnt[13];
int c[24];
int dfs(int d) {
  int res = 0;
  if (d == 12) {
    if (cnt[12] > 1) return 0;
    if (cnt[12] == 1) c[12] = 1;
    int a = 1;
    res = 100;
    for (long long i = (1); i < (24); i++) {
      if (c[i] == 1) {
        res = min(res, a);
        a = 1;
      } else {
        a++;
      }
    }
    res = min(res, a);
    return res;
  }
  if (cnt[d] == 0) return dfs(d + 1);
  if (cnt[d] == 1) {
    c[d] = 1;
    res = max(res, dfs(d + 1));
    c[d] = 0;
    c[24 - d] = 1;
    res = max(res, dfs(d + 1));
    c[24 - d] = 0;
  }
  if (cnt[d] == 2) {
    c[d] = 1;
    c[24 - d] = 1;
    return dfs(d + 1);
    c[d] = 0;
    c[24 - d] = 0;
  }
  if (cnt[d] > 2) return 0;
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> d(n);
  for (long long i = (0); i < (n); i++) {
    cin >> d[i];
    cnt[d[i]]++;
  }
  c[0] = 1;
  cout << dfs(1) << endl;
  return 0;
}
