#include <bits/stdc++.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...){};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<char>> dp(n + 1, vector<char>(1 << 24));
  dp[0][1] = true;
  for (int i = 1; i <= n; i++) {
    int d;
    cin >> d;
    for (int bits = 0; bits < (1 << 24); bits++) {
      if (dp[i - 1][bits]) {
        dp[i][bits | (1 << d)] = 1;
        if (d) {
          dp[i][bits | (1 << (24 - d))] = 1;
        }
      }
    }
  }
  int ans = 0;
  for (int bits = 0; bits < (1 << 24); bits++) {
    vector<int> ts = {0};
    if (dp[n][bits]) {
      for (int j = 1; j < 24; j++) {
        if ((bits >> j) & 1) {
          ts.push_back(j);
        }
      }
      printb(bits);
      prints(ts);
      if (ts.size() <= 1) {
        continue;
      }
      int mini = M;
      for (size_t i = 1; i < ts.size(); i++) {
        mini = min(mini, ts[i] - ts[i - 1]);
      }
      mini = min(mini, ts[0] + 24 - ts.back());
      ans = max(ans, mini);
    }
  }
  cout << ans << '\n';
}
