#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int mod = 1e9 + 7, INF = 1 << 30;
const double EPS = 1e-12, PI = 3.1415926535897932384626;
const ll LINF = 1LL << 60, lmod = 1e9 + 7;
const int MAX_N = 52;
int main() {
  int N, a[MAX_N];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  if (N >= 25) {
    cout << "0" << endl;
    return 0;
  }
  int ans = -INF;
  int b[MAX_N];
  for (int i = 0; i < 1 << N; i++) {
    int ind = 0;
    b[ind++] = 0;
    for (int j = 0; j < N; j++) {
      if (((1 << j) & i) != 0)
        b[ind++] = 24 - a[j];
      else
        b[ind++] = a[j];
    }
    sort(b, b + N + 1);
    int diff = 24 - b[N];
    for (int j = 0; j < N; j++) diff = min(diff, b[j + 1] - b[j]);
    ans = max(ans, diff);
  }
  cout << ans << endl;
  return 0;
}
