#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
  edge(int t, int c) : to(t), cost(c) {}
};
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int ddx[] = {1, 1, 1, 0, -1, -1, -1, 0}, ddy[] = {1, 0, -1, -1, -1, 0, 1, 1};
int n;
int d[51], cnt[51][51];
bool use[24];
vector<pair<int, int> > v;
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    pq;
int ans;
void f(int idx) {
  if (idx == n) {
    int ma = 1.1e9, prv = 0;
    for (int i = (1); i < (24); ++i) {
      if (use[i]) {
        ma = min(ma, i - prv);
        prv = i;
      }
    }
    ans = max(ans, ma);
    return;
  }
  if (!use[d[idx]]) {
    use[d[idx]] = true;
    f(idx + 1);
    use[d[idx]] = false;
  }
  if (!use[24 - d[idx]]) {
    use[24 - d[idx]] = true;
    f(idx + 1);
    use[24 - d[idx]] = false;
  }
  return;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = (0); i < (n); ++i) cin >> d[i];
  for (int i = (0); i < (24); ++i) use[i] = false;
  use[0] = true;
  f(0);
  cout << (ans == 1.1e9 ? 0 : ans) << endl;
  return 0;
}
