#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
static const double pi = 3.141592653589793;
int dif(int a, int b) {
  int d = abs(a - b);
  return min(d, 24 - d);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> nums(N);
  for (int i = 0; i < N; i++) cin >> nums[i];
  nums.push_back(0);
  int mx = 0;
  for (int i = 0; i < N; i++) {
    int mn = INF, base = nums[i];
    for (int j = 0; j < N + 1; j++) {
      if (i == j) continue;
      int d = max(dif(base, nums[j]), dif(base, (24 - nums[j])));
      if (mn > d) mn = d;
    }
    if (mx < mn) mx = mn;
  }
  cout << mx << endl;
  ;
}
