#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
int mn[1 << 24], n, d[50], cnt[13], ans;
vector<int> v;
int main() {
  cin >> n;
  v.emplace_back(0);
  cnt[0]++;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (cnt[d[i]] == 2) continue;
    cnt[d[i]]++;
    v.emplace_back(d[i]);
  }
  for (int i = 0; i < (1 << 24); i++) mn[i] = 1000;
  for (int i = 0; i < (1 << 24); i++) {
    int b = -1, fir = -1;
    for (int j = 0; j < 24; j++) {
      if (b == -1 && i & (1 << j))
        b = j, fir = j;
      else if (i & (1 << j)) {
        mn[i] = min(mn[i], j - b);
        b = j;
      }
    }
    if (b == fir) {
      mn[i] = 0;
      continue;
    }
    mn[i] = min(mn[i], fir + 24 - b);
  }
  for (int i = 0; i < (1 << (int)v.size()); i++) {
    int now = 1;
    int c[24] = {0};
    for (int j = 0; j < v.size(); j++) {
      if (i & (1 << j) || v[j] == 0)
        now |= (1 << v[j]), c[v[j]]++;
      else
        now |= (1 << (24 - v[j])), c[24 - v[j]]++;
    }
    for (int i = 0; i < 24; i++) {
      if (c[i] == 2) now = 0;
    }
    if (mn[now] == 1000) continue;
    ans = max(ans, mn[now]);
  }
  cout << ans << endl;
  return 0;
}
