#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
const int MAX_N = 51;
vector<int> times;
int8_t dp[MAX_N][1 << 24];
int8_t memo(int pos, int bit) {
  if (pos == N) {
    int res = 24;
    for (int i = 0; i <= 24; i++) {
      for (int j = i + 1; j <= 24; j++) {
        if (((bit >> i) & 1) and ((bit >> j) & 1)) {
          res = min(res, j - i);
          res = min(res, 24 - (i - j));
        }
      }
    }
    return res;
  }
  if (dp[pos][bit] != -1) {
    return dp[pos][bit];
  }
  int8_t res = -20;
  int8_t t1 = times[pos];
  int8_t t2 = 24 - times[pos];
  if (((bit >> t1) & 1) == 0) {
    res = max(res, memo(pos + 1, bit | (1 << t1)));
  }
  if (((bit >> t2) & 1) == 0) {
    res = max(res, memo(pos + 1, bit | (1 << t2)));
  }
  return res;
}
int main() {
  cin >> N;
  times.resize(N);
  for (auto &val : times) {
    cin >> val;
  }
  sort(times.begin(), times.end());
  if (times[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  memset(dp, -1, sizeof(dp));
  cout << max(0, int(memo(0, 1))) << endl;
  return 0;
}
