#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline bool chmax(A &a, B b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, typename B>
inline bool chmin(A &a, B b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1ll << 30;
const long long longINF = 1ll << 60;
const long long MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
int N;
int D[50];
bool dp[2][1 << 24];
int main() {
  cin >> N;
  for (int i = (0); i < (N); i++) scanf("%d", D + i);
  int cnt[13] = {};
  for (int i = (0); i < (N); i++) cnt[D[i]]++;
  bool ng = cnt[0];
  for (int i = (0); i < (N); i++) ng |= cnt[i] > 2;
  if (ng) {
    puts("0");
    return 0;
  }
  int ans = 0;
  for (int s = (0); s < (1 << N); s++) {
    int state = 1;
    bool ok = true;
    for (int i = (0); i < (N); i++) {
      if (s >> i & 1) {
        if (state >> (24 - D[i]) & 1) ok = false;
        state |= 1 << (24 - D[i]);
      } else {
        if (state >> D[i] & 1) ok = false;
        state |= 1 << D[i];
      }
    }
    if (!ok) continue;
    int cur = 100;
    for (int i = (0); i < (24); i++)
      if (state >> i & 1) {
        int cnt = 1;
        while (i + cnt < 48 && !(state >> ((i + cnt) % 24) & 1)) cnt++;
        chmin(cur, cnt);
        i = i + cnt - 1;
      }
    if (cur < 24) chmax(ans, cur);
  }
  cout << ans << endl;
  return 0;
}
