#include <bits/stdc++.h>
using namespace std;
long long N, D[51];
int main(void) {
  cin >> N;
  D[0] = 0;
  for (long long i = ((long long)1); i < ((long long)N + 1); i++) cin >> D[i];
  N++;
  if (N > 24) {
    cout << 0 << endl;
  } else {
    vector<long long> cnt(24);
    long long ans = 0;
    for (long long i = ((long long)0); i < ((long long)1LL << N); i++) {
      long long f = true;
      for (long long j = ((long long)0); j < ((long long)24); j++) cnt[j] = 0;
      for (long long j = ((long long)0); j < ((long long)N); j++) {
        long long d = ((i & (1LL << j)) == 0 ? D[j] : 24 - D[j]);
        if (d == 24) {
          f = false;
          break;
        }
        assert(0 <= d && d < 24);
        if (d > 0 && cnt[d] > 0) {
          f = false;
          break;
        }
        cnt[d]++;
      }
      if (!f) continue;
      long long s = (1LL << 60);
      for (long long j = ((long long)0); j < ((long long)24); j++)
        for (long long k = ((long long)j + 1); k < ((long long)24); k++)
          if (cnt[j] > 0 && cnt[k] > 0) s = min(s, min(k - j, 24 - (k - j)));
      if (s == (1LL << 60)) s = 0;
      ans = max(ans, s);
    }
    cout << ans << endl;
  }
}
