#include <bits/stdc++.h>
int read() {
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  int k = 1, kk = 0;
  if (c == '-') c = getchar(), k = -1;
  while (c >= '0' && c <= '9') kk = kk * 10 + c - '0', c = getchar();
  return k * kk;
}
using namespace std;
int n, mi, a[1000], ff, f[1000];
bool pd(int x) {
  for (int i = 1; i <= n; i++) {
    ff = 0;
    f[i] = a[i];
    for (int j = 0; j < i; j++)
      if (min(max(f[i], f[j]) - min(f[i], f[j]),
              min(f[i], f[j]) - max(f[i], f[j]) + 24) < x)
        ff = 1;
    if (ff) ff = 0, f[i] = 24 - a[i];
    for (int j = 0; j < i; j++)
      if (min(max(f[i], f[j]) - min(f[i], f[j]),
              min(f[i], f[j]) - max(f[i], f[j]) + 24) < x)
        ff = 1;
    if (ff) return 0;
  }
  return 1;
}
int main() {
  n = read();
  mi = 100;
  for (int i = 1; i <= n; i++) a[i] = read(), mi = min(mi, a[i]);
  for (int i = mi; i >= 0; i--)
    if (pd(i)) {
      cout << i << endl;
      return 0;
    }
}
