#include <bits/stdc++.h>
using namespace std;
int n;
int d[55];
vector<pair<int, int> > a;
bool used[55];
bool ok(int x) {
  int i = 1;
  int crth = 0;
  int cnt = 1;
  memset(used, 0, sizeof(used));
  used[0] = true;
  while (1) {
    while (i < a.size() && (a[i].first - crth < x || used[a[i].second])) i++;
    if (i == a.size()) return false;
    used[a[i].second] = true;
    cnt++;
    if (cnt == n + 1) return true;
    crth = a[i].first;
  }
  return false;
}
int main() {
  cin >> n;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    cin >> d[i];
    if (d[i] == 0 || d[i] == 12) {
      a.push_back(pair<int, int>(d[i], i + 1));
    } else {
      a.push_back(pair<int, int>(d[i], i + 1));
      a.push_back(pair<int, int>(24 - d[i], i + 1));
    }
  }
  a.push_back(pair<int, int>(0, 0));
  sort((a).begin(), (a).end());
  for (long long x = (long long)(0); x < (long long)(25); x++) {
    if (!ok(x)) {
      cout << x - 1 << endl;
      return 0;
    }
  }
  return 0;
}
