#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double EPS = 1e-10;
int bitcount(int bits) {
  int num;
  num = (bits >> 1) & 03333333333;
  num = bits - num - ((num >> 1) & 03333333333);
  num = ((num + (num >> 3)) & 0707070707) % 077;
  return num;
}
int n, m;
long long k;
string s;
int ans = 0;
int a[50];
struct UF {
  int data[51 * 2];
  int rk[51 * 2];
  int n;
  void init(int n) {
    this->n = n;
    for (int i = (0); i < (n); ++i) {
      data[i] = i;
      rk[i] = 0;
    }
  }
  bool find(int i) { return i == data[i] ? i : data[i] = find(data[i]); }
  bool same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (rk[a] < rk[b]) {
      data[a] = b;
    } else {
      data[b] = a;
      if (rk[a] == rk[b]) rk[b]++;
    }
  }
};
UF tree;
bool solve(int x) {
  tree.init(n);
  for (int i = (0); i < (1 << n); ++i)
    if (bitcount(i) == 2) {
      int f = -1, s = 0;
      for (int j = (0); j < (n); ++j)
        if (i & (1 << j)) {
          if (f < 0)
            f = j;
          else
            s = j;
        };
      if (abs(a[f] - a[s]) < x) {
        if (tree.same(f, s + n)) return false;
        tree.unite(f, s);
        tree.unite(f + n, s + n);
      }
      if (abs(a[f] + a[s] - 24) < x) {
        if (tree.same(f, s)) return false;
        tree.unite(f, s + n);
        tree.unite(f + n, s);
      }
    }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = (0); i < (n); ++i) cin >> a[i + 1];
  n++;
  int low = 0, high = 12;
  while (low < high) {
    int mid = (low + high + 1) / 2;
    if (solve(mid))
      low = mid;
    else
      high = mid - 1;
  }
  cout << low << endl;
}
