#include <bits/stdc++.h>
using namespace std;
const int maxx = 10005;
int n, m, k;
vector<int> a;
int ans = 0, cnt = 0, pos = 0;
int l = 0, r = 0;
void f() {
  int mi = 24;
  pos = -1;
  while (1) {
    sort(a.begin(), a.end());
    for (int i = 1; i < n; i++) {
      if (mi > a[i] - a[i - 1]) {
        mi = a[i] - a[i - 1];
        pos = i;
      }
    }
    for (auto it = a.begin(); it != a.end(); ++it) {
    }
    auto t1 = lower_bound(a.begin(), a.end(), 24 - a[pos]) - a.begin() - 1;
    int dif1, dif2;
    dif1 = min(24 - a[pos] - a[t1], a[t1 + 1] + a[pos] - 24) - mi;
    auto t2 = lower_bound(a.begin(), a.end(), 24 - a[pos - 1]) - a.begin() - 1;
    dif2 = min(24 - a[pos - 1] - a[t2], a[t2 + 1] + a[pos - 1] - 24) - mi;
    if (dif1 <= 0 && dif2 <= 0) break;
    if (dif1 > dif2) {
      a[pos] = 24 - a[pos];
    } else {
      a[pos - 1] = 24 - a[pos - 1];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  a.push_back(0);
  a.push_back(24);
  n += 2;
  f();
  int mi = 24;
  for (int i = 1; i < n; i++) {
    mi = min(mi, a[i] - a[i - 1]);
  }
  printf("%d\n", mi);
  return 0;
}
