#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
const double EPS = 1e-6;
using namespace std;
int a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  int tt = 0x3f3f3f3f, r;
  for (int i = 1; i < (n + 1); ++i) {
    scanf("%d", &a[i]);
    if (a[i] < tt) tt = a[i], r = i;
  }
  if (n == 1) return printf("%d\n", min(a[1], 24 - a[1])), 0;
  int l;
  for (int i = 1; i < (n + 1); ++i) {
    for (int j = i + 1; j < (n + 1); ++j) {
      if (abs(a[i] - a[j]) < tt) {
        tt = 0x3f3f3f3f;
        l = i;
        r = j;
      }
    }
  }
  a[r] = 24 - a[r];
  int mx = 0x3f3f3f3f;
  for (int i = 1; i < (n + 1); ++i) {
    for (int j = i + 1; j < (n + 1); ++j) {
      mx = min(mx, abs(a[i] - a[j]));
    }
  }
  cout << mx << endl;
  return 0;
}
