#include <bits/stdc++.h>
using namespace std;
template <class T>
using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
char moji[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char moji2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char moji3[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
bool Add(long long &a, long long b) { a = (a + b) % long long(1e9 + 7); }
void myprint(long long *A, long long A_num) {
  for (long long i = 0; i < A_num; i++) cout << A[i] << " ";
  cout << endl;
}
signed main() {
  long long n;
  cin >> n;
  long long D[n];
  for (long long i = 0; i < n; i++) cin >> D[i];
  if (n > 23) {
    cout << 0 << endl;
    return 0;
  }
  long long ju = 1;
  for (long long i = 0; i < n; i++) {
    ju *= 2;
  }
  long long mask = 0;
  long long ans = 0;
  long long jikoku[n + 2];
  jikoku[0] = 0;
  jikoku[n + 1] = 24;
  while (mask < ju) {
    long long tmp = 1;
    for (long long i = 0; i < n; i++) {
      if ((mask & tmp))
        jikoku[i + 1] = D[i];
      else
        jikoku[i + 1] = 24 - D[i];
      tmp *= 2;
    }
    sort(jikoku, jikoku + n + 1);
    long long hoge = 25;
    for (long long i = 0; i < n; i++) {
      chmin(hoge, jikoku[i + 1] - jikoku[i]);
    }
    chmax(ans, hoge);
    mask++;
  }
  cout << ans % 24 << endl;
}
