#include <bits/stdc++.h>
using namespace std;
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int dfs(vector<int> &v, vector<int> t, int index) {
  if (index == 13) {
    vector<int> x;
    for (int i = (0); i < (t.size()); i++) {
      if (t[i]) x.push_back(i);
    }
    for (int i = (0); i < (t.size()); i++) {
      if (t[i]) x.push_back(i);
    }
    int ret(INF);
    for (int i = (0); i < (x.size() - 1); i++) {
      chmin(ret, min(abs(x[i] - x[i + 1]), 24 - abs(x[i] - x[i + 1])));
    }
    return ret;
  }
  if (v[index] == 0) {
    return dfs(v, t, index + 1);
  } else if (v[index] == 1) {
    t[index] = 1;
    int a = dfs(v, t, index + 1);
    t[index] = 0;
    t[(24 - index) % 24] = 1;
    int b = dfs(v, t, index + 1);
    return max(a, b);
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = (0); i < (N); i++) cin >> D[i];
  vector<int> t(25, 0);
  t[0] = 1;
  vector<int> v(13, 0);
  for (int i = (0); i < (D.size()); i++) {
    v[D[i]]++;
  }
  for (int i = (0); i < (v.size()); i++) {
    if (v[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = (0); i < (v.size()); i++) {
    if (v[i] == 2) {
      t[i] = 1;
      t[(24 - i) % 24] = 1;
      v[i] = 0;
    }
  }
  cout << dfs(v, t, 1) << endl;
  return 0;
}
