#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (auto &i : d) cin >> i;
  d.push_back(0);
  if (n >= 24) {
    cout << 0 << endl;
    return 0;
  }
  if (n > 12) {
    int a[13] = {};
    for (int i = 0; i <= n; ++i) {
      a[d[i]]++;
    }
    bool f = a[0] < 2 && a[12] < 2;
    for (int i = 1; i < 12; ++i) {
      if (a[i] > 3) f = false;
    }
    cout << f << endl;
    return 0;
  }
  int ans = 0;
  vector<int> a(n + 1);
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < d.size(); ++j) {
      if (i & (1 << j)) {
        a[j] = d[j];
      } else {
        a[j] = 24 - d[j];
      }
    }
    int diff = 1001001;
    for (int j = 0; j < a.size(); ++j) {
      for (int k = 0; k < a.size(); k++) {
        if (j == k) continue;
        diff = min(diff, min(abs(a[j] - a[k]), 24 - abs(a[j] - a[k])));
      }
    }
    ans = max(diff, ans);
  }
  cout << ans << endl;
}
