#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> d(N);
    long long ans = 0;
    for (long long i = ((long long)0); i < ((long long)1LL << N); i++) {
      for (long long j = ((long long)0); j < ((long long)N); j++)
        d[j] = ((i & (1LL << j)) == 0 ? D[j] : 24 - D[j]);
      long long s = (1LL << 60);
      for (long long j = ((long long)0); j < ((long long)N); j++)
        for (long long k = ((long long)j + 1); k < ((long long)N); k++)
          s = min(s, min(abs(d[j] - d[k]), 24 - abs(d[j] - d[k])));
      ans = max(ans, s);
    }
    cout << ans << endl;
  }
}
