#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N;
  cin >> N;
  std::vector<long long> v(N);
  for (long long i = 0; i < N; i++) cin >> v[i];
  if (N >= 23) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  std::vector<long long> w(N + 1);
  w[0] = 0;
  for (long long i = 0; i < pow(2, N); i++) {
    long long k = 1;
    for (long long j = 0; j < N; j++) {
      if (v[j] == 0) {
        w[j + 1] = 0;
        continue;
      }
      if (i & k)
        w[j + 1] = v[j];
      else
        w[j + 1] = 24 - v[j];
      k *= 2;
    }
    sort(w.begin(), w.end());
    long long fans = 12;
    for (long long j = 0; j < N; j++) fans = min(fans, w[j + 1] - w[j]);
    ans = max(fans, ans);
  }
  cout << ans << endl;
  return 0;
}
