#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int D[N];
  for (int i = 0; i < N; ++i) cin >> D[i];
  sort(D, D + N);
  if (N > 36) {
    cout << "0" << endl;
    return 0;
  }
  vector<int> dp(1 << 24, 0);
  dp[1] = 24;
  for (int i = 0; i < N; ++i) {
    vector<int> dp_(1 << 24, 0);
    for (int j = 1; j < (1 << 24); ++j) {
      int t1 = (1 << (D[i])), t2 = (1 << ((24 - D[i]) % 24));
      if ((j & t1) == 0) {
        int d = dp[j];
        for (int k = 0; k < 24; ++k) {
          if ((j >> k) & 1) d = min(d, abs(D[i] - k));
        }
        dp_[j | t1] = max(dp_[j | t1], d);
      }
      if ((j & t2) == 0) {
        int d = dp[j];
        for (int k = 0; k < 24; ++k) {
          if ((j >> k) & 1) d = min(d, abs((24 - D[i]) % 24 - k));
        }
        dp_[j | t2] = max(dp_[j | t2], d);
      }
    }
    dp = dp_;
  }
  int ans = 0;
  for (int i = 0; i < (1 << 24); ++i) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}
