#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
bool getBit(int num, int i) { return ((num & (1 << i)) != 0); }
int setBit(int num, int i) { return num | (1 << i); }
int clearBit(int num, int i) {
  int mask = ~(1 << i);
  return num & mask;
}
int updateBit(int num, int i, int v) {
  int mask = ~(1 << i);
  return (num & mask) | (v << i);
}
int main() {
  int n;
  cin >> n;
  map<int, int> m;
  vector<int> v;
  bool f = false;
  for (int i = 0; i < (n); i++) {
    int d;
    cin >> d;
    m[d]++;
    if (m[d] >= 3) f = true;
  }
  if (f) {
    cout << 0 << endl;
    return 0;
  }
  for (auto i : m) {
    for (int j = 0; j < (i.second); j++) v.emplace_back(i.first);
  }
  int ans = 0;
  for (int i = 0; i < (1 << v.size()); i++) {
    vector<int> a, b;
    for (int j = 0; j < (v.size()); j++) {
      if (getBit(i, j)) {
        a.emplace_back(v[j]);
        b.emplace_back(24 - v[j]);
      } else {
        a.emplace_back(24 - v[j]);
        b.emplace_back(v[j]);
      }
    }
    a.emplace_back(0);
    b.emplace_back(24);
    int mini = INF;
    for (int j = 0; j < (a.size()); j++) {
      for (int k = 0; k < (a.size()); k++) {
        if (j == k) continue;
        int dif = abs(a[j] - a[k]);
        mini = min(mini, min(dif, 24 - dif));
      }
    }
    for (int j = 0; j < (b.size()); j++) {
      for (int k = 0; k < (b.size()); k++) {
        if (j == k) continue;
        int dif = abs(b[j] - b[k]);
        mini = min(mini, min(dif, 24 - dif));
      }
    }
    ans = max(ans, mini);
  }
  cout << ans << endl;
}
