#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void upmin(T &x, T y) {
  y < x ? x = y : 0;
}
template <typename T>
inline void upmax(T &x, T y) {
  x < y ? x = y : 0;
}
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long OO = 1e18;
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
inline int dis(int a, int b) { return min(b - a, 24 - b + a); }
int main() {
  int n = gi(), i, s[13] = {}, x[52] = {}, y[52] = {}, f, ans = 0, mi;
  for (i = 0; i < n; i++) s[x[i] = gi()]++;
  if (n == 1) return puts("0"), 0;
  for (i = 0; i <= 12; i++)
    if (s[i] >= 3) return puts("0"), 0;
  for (f = 0; f < 1 << n; f++) {
    for (i = 0; i < n; i++) y[i] = f >> i & 1 ? x[i] : 24 - x[i];
    sort(y, y + n);
    mi = min(dis(0, y[n - 1]), dis(0, y[0]));
    for (i = 1; i < n; i++) upmin(mi, dis(y[i - 1], y[i]));
    upmax(ans, mi);
  }
  cout << ans << endl;
  return 0;
}
