#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
void solve(vector<bool>& t, vector<long long int>& d,
           vector<long long int>& ans, long long int i) {
  if (i > 12) {
    vector<long long int> s;
    for (long long int j = 0; j < 24; j++) {
      if (t[j]) {
        s.push_back(j);
      }
    }
    long long int minT = INF;
    for (long long int j = 0; j < (long long int)s.size() - 1; j++) {
      long long int time = s[j + 1] - s[j];
      time = min(time, 24 - time);
      if (time < minT) {
        minT = time;
      }
    }
    ans.push_back(minT);
    return;
  }
  if (d[i] == 0) {
    solve(t, d, ans, i + 1);
  } else {
    t[i] = true;
    solve(t, d, ans, i + 1);
    t[i] = false;
    t[24 - i] = true;
    solve(t, d, ans, i + 1);
    t[24 - i] = false;
  }
}
signed main() {
  long long int n;
  cin >> n;
  vector<long long int> d(13);
  d[0] = 1;
  for (long long int i = 0; i < (n); ++i) {
    long long int x;
    cin >> x;
    d[x]++;
  }
  vector<bool> t(24, false);
  for (long long int i = 1; i <= 12; i++) {
    if (d[i] == 2) {
      t[i] = true;
      t[24 - i] = true;
      d[i] = 0;
    }
    if (d[i] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (d[0] == 1) {
    t[0] = true;
  }
  if (d[0] > 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<long long int> ans;
  solve(t, d, ans, 1);
  cout << *max_element(ans.begin(), ans.end()) << endl;
  return 0;
}
