#include <bits/stdc++.h>
using namespace std;
int dfs(list<int> fixed, list<int> free) {
  list<int> lf(fixed);
  if (free.size() == 0) {
    if (fixed.size() == 1) return fixed.front();
    fixed.sort();
    int m = INT32_MAX;
    int a = fixed.front();
    int n = fixed.size();
    for (int i = 0; i < (int)(n - 1); i++) {
      fixed.pop_front();
      int b = fixed.front();
      int d = b - a;
      m = min(m, d);
      a = b;
    }
    return m;
  } else {
    list<int> c1(fixed);
    list<int> c2(fixed);
    c1.push_back(free.front());
    c2.push_back(24 - free.front());
    free.pop_front();
    return max(dfs(c1, free), dfs(c2, free));
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < (int)(n); i++) cin >> d[i];
  vector<int> c(13);
  for (int i = 0; i < (int)(n); i++) c[d[i]]++;
  int m = c.size();
  if (*max_element(c.begin(), c.end()) >= 3) {
    cout << 0 << endl;
    return 0;
  }
  if (c[0] >= 1 || c[12] >= 2) {
    cout << 0 << endl;
    return 0;
  }
  list<int> free;
  list<int> fixed;
  fixed.push_back(0);
  if (c[12] != 0) fixed.push_back(12);
  for (int i = 1; i < m - 1; i++) {
    if (c[i] == 1) {
      free.push_back(i);
    } else if (c[i] == 2) {
      fixed.push_back(i);
      fixed.push_back(24 - i);
    }
  }
  cout << dfs(fixed, free) << endl;
  return 0;
}
