#include <bits/stdc++.h>
using namespace std;
const int iinf = 1 << 29;
const long long linf = 1ll << 61;
template <typename T>
inline T gcd(T x, T y) {
  if (x < y) swap(x, y);
  T mod = x % y;
  if (mod == 0) return y;
  return gcd(y, mod);
}
template <typename T>
inline T lmc(T x, T y) {
  return x / gcd(x, y) * y;
}
int N;
int D[50];
int main(int argc, char* argv[]) {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &D[i]);
  int ans = 0;
  for (int i = 1; i < N; i++) {
    int k = D[i];
    int m = iinf;
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      int s = D[j];
      int t = 24 - D[j];
      m = min(m, max(abs(min((((24) + (k - s) % (24)) % (24)),
                             (((24) + (s - k) % (24)) % (24)))),
                     abs(min((((24) + (k - t) % (24)) % (24)),
                             (((24) + (t - k) % (24)) % (24))))));
    }
    k = 24 - D[i];
    int n = iinf;
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      int s = D[j];
      int t = 24 - D[j];
      n = min(n, max(abs(min((((24) + (k - s) % (24)) % (24)),
                             (((24) + (s - k) % (24)) % (24)))),
                     abs(min((((24) + (k - t) % (24)) % (24)),
                             (((24) + (t - k) % (24)) % (24))))));
    }
    ans = max({ans, m, n});
  }
  printf("%d\n", ans);
  return 0;
}
