#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  vector<int> v;
  map<int, int> mp;
  cin >> n;
  for (int i = 0; i <= 12; i++) mp[i] = 0;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    mp[d]++;
    if (d == 0 || d == 12) v.push_back(d);
    if (mp[d] == 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < 1 << 11; i++) {
    while (v.size() != 0) v.pop_back();
    for (int j = 0; j < mp[0]; j++) v.push_back(0);
    for (int j = 0; j < mp[12]; j++) v.push_back(12);
    for (int j = 0; j < 11; j++) {
      if (mp[j + 1] == 2) {
        v.push_back(j + 1);
        v.push_back(23 - j);
      } else if (mp[j + 1] == 1) {
        if ((1 & i >> j) == 0)
          v.push_back(j + 1);
        else
          v.push_back(23 - j);
      }
    }
    int m = 100;
    for (int j = 0; j < v.size(); j++)
      for (int k = j + 1; k < v.size(); k++)
        m = min(m, max(v[j] - v[k], v[k] - v[j]));
    ans = max(ans, m);
  }
  cout << ans << endl;
}
