#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int n;
vector<int> d;
int calc_diff() {
  int ret = 1410065408;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j <= n - 1; j++) {
      int diff = abs(d[i] - d[j]);
      diff = min(diff, 24 - diff);
      ret = min(ret, diff);
    }
  }
  return ret;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n == 1) {
    int d;
    cin >> d;
    cout << d << endl;
    return 0;
  }
  if (n + 1 >= 24) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    d.push_back(tmp);
  }
  sort(d.begin(), d.end());
  for (int i = 1; i < n; i += 2) {
    d[i] = 24 - d[i];
  }
  int ans1 = calc_diff();
  for (int i = 0; i < n; i++) {
    d[i] = 24 - d[i];
  }
  int ans2 = calc_diff();
  cout << max(ans1, ans2) << endl;
  return 0;
}
