#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int(i) = 0; (i) < (int)(N); (i)++) cin >> D[i];
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  int cnt[13] = {};
  for (int(i) = 0; (i) < (int)(D.size()); (i)++) cnt[D[i]]++;
  for (int(i) = 0; (i) < (int)(13); (i)++)
    if (cnt[i] > 2) {
      cout << 0 << endl;
      return 0;
    }
  vector<int> one;
  vector<int> two;
  for (int(i) = 0; (i) < (int)(13); (i)++) {
    if (cnt[i] == 1) one.push_back(i);
    if (cnt[i] == 2) two.push_back(i);
  }
  D.clear();
  for (int(i) = 0; (i) < (int)(one.size()); (i)++) D.push_back(one[i]);
  for (int(i) = 0; (i) < (int)(two.size()); (i)++)
    D.push_back(two[i]), D.push_back(24 - two[i]);
  bool asone[13];
  for (int(i) = 0; (i) < (int)(13); (i)++) asone[i] = false;
  for (int(i) = 0; (i) < (int)(one.size()); (i)++) asone[one[i]] = true;
  int ans = 0;
  for (int(i) = 0; (i) < (int)((1 << one.size())); (i)++) {
    int trans[13];
    for (int(j) = 0; (j) < (int)(one.size()); (j)++) {
      if ((i >> j) & 1) {
        trans[one[j]] = one[j];
      } else {
        trans[one[j]] = 24 - one[j];
      }
    }
    vector<int> Dt = D;
    for (int(j) = 0; (j) < (int)(Dt.size()); (j)++)
      if (asone[Dt[j]]) {
        Dt[j] = trans[Dt[j]];
      }
    int diff = 1e9;
    for (int(j) = 0; (j) < (int)(Dt.size()); (j)++)
      for (int(k) = 0; (k) < (int)(Dt.size()); (k)++) {
        if (j != k) {
          diff = min(diff, abs(Dt[j] - Dt[k]));
        }
      }
    ans = max(ans, diff);
  }
  cout << ans << endl;
  return 0;
}
