#include <bits/stdc++.h>
using namespace std;
template <class A>
void pr(A a) {
  cout << a;
  cout << '\n';
}
template <class A, class B>
void pr(A a, B b) {
  cout << a << ' ';
  pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
  cout << a << ' ';
  pr(b, c);
}
template <class A, class B, class C, class D>
void pr(A a, B b, C c, D d) {
  cout << a << ' ';
  pr(b, c, d);
}
template <class A>
void PR(A a, long long n) {
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (i) cout << ' ';
    cout << a[i];
  }
  cout << '\n';
}
long long check(long long n, long long m, long long x, long long y) {
  return x >= 0 && x < n && y >= 0 && y < m;
}
const long long MAX = 1000000007, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
                dy[4] = {0, 1, 0, -1};
bool dp[2][1 << 24];
void Main() {
  int n;
  cin >> n;
  n++;
  if (n >= 24) {
    pr(0);
    return;
  }
  int d[n], r = 0;
  d[0] = 0;
  for (long long i = (long long)(1); i < (long long)(n); i++) cin >> d[i];
  sort(d, d + n);
  dp[0][1] = 1;
  for (long long i = (long long)(1); i < (long long)(n); i++) {
    for (long long t = (long long)(0); t < (long long)(1 << 24); t++) {
      if (!dp[r][t]) continue;
      int x = d[i];
      if (!(t & (1 << x))) dp[r ^ 1][t | (1 << x)] |= 1;
      x = (24 - d[i]) % 24;
      if (!(t & (1 << x))) dp[r ^ 1][t | (1 << x)] |= 1;
    }
    r ^= 1;
  }
  int ans = 0;
  for (long long t = (long long)(0); t < (long long)(1 << 24); t++) {
    if (!dp[r][t] || __builtin_popcount(t) != n) continue;
    vector<int> v;
    for (long long i = (long long)(0); i < (long long)(24); i++) {
      if (t & (1 << i)) v.push_back(i);
    }
    int x = MAX;
    for (long long i = (long long)(0); i < (long long)(v.size()); i++) {
      int y = abs(v[(i + 1) % v.size()] - v[i]);
      y = min(y, 24 - y);
      x = min(x, y);
    }
    ans = max(ans, x);
  }
  pr(ans);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}
