#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAX_N = 50;
const int MAX_BIT = (1 << 24);
int calcDiff(int t, int bit) {
  int ret = t;
  for (int i = 0; i < 24; i++) {
    if ((bit >> i) & 1) {
      int time = i;
      ret = min(ret, abs(time - t));
    }
  }
  return ret;
}
int main() {
  int N;
  static int dp[2][MAX_BIT];
  cin >> N;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    vec.push_back(tmp);
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < MAX_BIT; j++) {
      dp[i][j] = -1;
    }
  }
  int now = 0;
  int next = 1;
  dp[now][0] = INF;
  int res = -1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_BIT; j++) {
      if (dp[now][j] == -1) continue;
      vector<int> cand;
      cand.push_back(vec[i]);
      cand.push_back((24 - vec[i]) % 24);
      for (int k = 0; k < cand.size(); k++) {
        int min_time = min(calcDiff(cand[k], j), dp[now][j]);
        int next_bit = (j | (1 << cand[k]));
        dp[next][next_bit] = max(dp[next][next_bit], min_time);
        if (i + 1 == N) {
          res = max(res, dp[next][next_bit]);
        }
      }
    }
    swap(now, next);
    for (int j = 0; j < MAX_BIT; j++) {
      dp[next][j] = -1;
    }
  }
  cout << res << endl;
  return 0;
}
