#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
const long long INF = 1001001001001001LL;
const long long MOD = 1000000007LL;
long long int N, cnt[15];
signed main() {
  cin >> N;
  for (long long int(i) = (0); (i) < (N); (i)++) {
    long long int p;
    cin >> p;
    cnt[p]++;
  }
  vector<long long int> decided, tasks;
  decided.push_back(0);
  for (long long int(k) = (0); (k) <= (12); (k)++) {
    long long int lim = 2;
    if (k == 0) lim = 0;
    if (k == 12) lim = 1;
    if (lim < cnt[k]) {
      cout << 0 << endl;
      return 0;
    }
    if (cnt[k] == 2) {
      decided.push_back(k);
      decided.push_back(24 - k);
    } else if (cnt[k] == 1) {
      tasks.push_back(k);
    }
  }
  long long int M = tasks.size(), ans = 0;
  for (long long int(bit) = (0); (bit) < (1 << M); (bit)++) {
    vector<long long int> temp = decided;
    for (long long int(k) = (0); (k) < (M); (k)++) {
      if (bit >> k & 1) {
        temp.push_back(tasks[k]);
      } else {
        temp.push_back(24 - tasks[k]);
      }
    }
    sort(temp.begin(), temp.end());
    long long int S = temp.size(), mi = INF;
    for (long long int(i) = (0); (i) < (S); (i)++) {
      long long int diff = abs(temp[i] - temp[i + 1]);
      chmin(mi, min(diff, 24 - diff));
    }
    chmax(ans, mi);
  }
  cout << ans << endl;
  return 0;
}
