#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
template <class T>
void vin(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int n;
int d[52];
int dp[2][52];
int main() {
  cin >> n;
  d[0] = 0;
  for (int(i) = (0); (i) < (int)(n); ++(i)) cin >> d[i + 1];
  n++;
  for (int(i) = (0); (i) < (int)(n); ++(i)) {
    for (int(j) = (0); (j) < (int)(2); ++(j)) {
      if (d[i] == 0) {
        dp[0][i] = dp[1][i] = d[i];
      } else {
        if (j)
          dp[j][i] = d[i];
        else
          dp[j][i] = 24 - d[i];
      }
    }
  }
  int ans = -1e8;
  for (int f = 0; f < (1 << n); ++f) {
    int tmp = 1e8;
    for (int(i) = (0); (i) < (int)(n); ++(i)) {
      for (int(j) = (0); (j) < (int)(n); ++(j)) {
        if (i == j) continue;
        tmp = min(tmp, abs(dp[f & (1 << i)][i] - dp[f & (1 << j)][j]));
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
