#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long N;
long long D[51];
bool used[24];
long long cnt;
int main() {
  cin >> N;
  for (int(i) = 0; (i) < (N); ++i) cin >> D[i];
  if (N == 1) {
    cout << min(24 - D[0], D[0]) << endl;
    return 0;
  }
  if (N >= 24) {
    puts("0");
    return 0;
  }
  long long ans = 0;
  for (int(s) = 0; (s) < (1 << (N - 1)); ++s) {
    for (int(i) = 0; (i) < (24); ++i) used[i] = 0;
    used[0] = used[D[N - 1]] = 1;
    for (int(i) = 0; (i) < (N - 1); ++i) {
      if ((s >> i) & 1LL) {
        if (used[D[i]]) {
          goto en;
        }
        used[D[i]] = 1;
      } else {
        if (used[24 - D[i]]) {
          goto en;
        }
        used[24 - D[i]] = 1;
      }
    }
    cnt = 8LL;
    long long pos, pas;
    pas = 0;
    for (int(i) = 1; (i) <= (23LL); ++i) {
      while (i < 24LL && !used[i]) {
        i++;
      }
      if (i == 24LL) break;
      pos = i;
      cnt = min(cnt, pos - pas);
      pas = pos;
    }
    cnt = min(24LL - pas, cnt);
    ans = max(ans, cnt);
  en:;
  }
  cout << ans << endl;
}
