#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const double eps = 1e-10;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int d[51];
  cin >> N;
  for (int i = 0; i < (N); i++) {
    cin >> d[i];
  }
  if (N > 23) {
    cout << 0 << endl;
    return 0;
  }
  int res = 0;
  int D[51] = {};
  for (int i = 0; i < (1 << N); i++) {
    D[0] = 0;
    int ret = (int)1e9;
    for (int j = 0; j < (N); j++) {
      D[j + 1] = (i >> j) & 1 ? d[j] : 24 - d[j];
    }
    sort(D, D + N + 1);
    for (int j = 0; j < (N + 1); j++) {
      ret = min(ret, abs(D[j] - D[(j + 1) % N]));
    }
    res = max(ret, res);
  }
  cout << res << endl;
}
