#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
static const double pi = 3.141592653589793;
vector<int> tims;
int mn = INF;
int ck(int d) {
  int res = INF;
  for (auto t : tims) res = min(res, abs(t - d));
  ;
  return res;
}
void ins(int d) {
  int res;
  if (d != 0 && d != 12) {
    if (ck(d) < ck(24 - d)) d = 24 - d;
  }
  res = ck(d);
  tims.push_back(d);
  mn = min(mn, res);
  ;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<int, int> dic;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    dic[d]++;
  }
  tims.push_back(0);
  for (auto a : dic) {
    int d = a.first;
    int n = a.second;
    if (n >= 3) {
      mn = 0;
      break;
    }
    if (n >= 2) ins(d);
    if (n >= 1) ins(d);
  }
  cout << mn << endl;
}
