#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INF = INT_MAX / 2;
int main() {
  int N;
  cin >> N;
  int D[2][N];
  for (int i = 0; i < (N); i++) {
    cin >> D[0][i];
    D[1][i] = 24 - D[0][i];
  }
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < ((1 << N)); i++) {
    int x[N];
    for (int j = 0; j < (N); j++) x[j] = D[(i >> j) & 1][j];
    int tmp = INF;
    for (int j = 0; j < (N - 1); j++) {
      for (int k = j + 1; k < N; k++) {
        tmp = min(tmp, abs(x[j] - x[k]));
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
