#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int freq[13];
  for (int i = 0; i < 13; i++) {
    freq[i] = 0;
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    assert(x <= 12);
    freq[x]++;
  }
  vector<int> def;
  vector<int> li;
  if (freq[0] > 0) {
    cout << 0 << endl;
    return 0;
  }
  def.push_back(0);
  for (int i = 1; i < 13; i++) {
    if (freq[i] == 0) {
      continue;
    } else if (freq[i] == 1) {
      li.push_back(i);
    } else {
      def.push_back(i);
      def.push_back(24 - i);
    }
  }
  int nn = li.size();
  int len = (1 << nn);
  int ans = -1;
  int defs = def[1];
  for (int i = 0; i < def.size(); i++) {
    for (int j = i + 1; j < def.size(); j++) {
      int ab = abs(def[i] - def[j]);
      ab = min(ab, 24 - ab);
      defs = min(defs, ab);
    }
  }
  ans = -1;
  for (int ma = 0; ma < len; ma++) {
    vector<int> temp;
    for (int j = 0; j < nn; j++) {
      bool on = ((1 << j) & ma) != 0;
      if (on) {
        temp.push_back(li[j]);
      } else {
        temp.push_back(24 - li[j]);
      }
    }
    int now = defs;
    for (int i = 0; i < nn; i++) {
      for (int j = i + 1; j < nn; j++) {
        int ab = abs(temp[i] - temp[j]);
        ab = min(ab, 24 - ab);
        now = min(now, ab);
      }
    }
    for (int i = 0; i < nn; i++) {
      for (int j = 0; j < def.size(); j++) {
        int ab = abs(temp[i] - def[j]);
        ab = min(ab, 24 - ab);
        now = min(now, ab);
      }
    }
    ans = max(ans, now);
  }
  assert(ans >= 0);
  cout << ans << endl;
  return 0;
}
