#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> v(13);
  for (int i = 0; i < (int)(n); i++) {
    int d;
    cin >> d;
    v[d]++;
  }
  bool ok = true;
  for (int i = 0; i < (int)(13); i++)
    if (v[i] >= 3) ok = false;
  if (v[0] != 0) ok = false;
  if (v[12] >= 2) ok = false;
  if (!ok) {
    cout << "0" << endl;
    return 0;
  }
  vector<int> u(25), x;
  for (int i = 1; i <= 11; i++) {
    if (v[i] == 2) {
      u[i] = 1;
      u[24 - i] = 1;
    }
    if (v[i] == 1) x.push_back(i);
  }
  if (v[12] == 1) {
    v[12] = 0;
    u[12] = 1;
  }
  u[0] = 1;
  int ans = 0;
  for (int bit = 0; bit < (1 << (int)(x.size())); bit++) {
    auto y = u;
    for (int i = 0; i < (int)(x.size()); i++) {
      if (bit & (1 << i))
        y[24 - x[i]] = 1;
      else
        y[x[i]] = 1;
    }
    int s = 1e9;
    for (int i = 0; i < (int)(y.size()); i++) {
      if (y[i] == 0) continue;
      for (int j = 0; j < (int)(y.size()); j++) {
        if (y[j] == 1 && i != j) s = min(s, abs(i - j));
      }
    }
    ans = max(ans, s);
  }
  cout << ans << endl;
}
