#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;
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    vector<int> a(n + 1);
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        a[j] = d[j];
      } else {
        a[j] = 24 - d[j];
      }
    }
    sort(a.begin(), a.end());
    int diff = min(a.back(), 24 - a.back());
    for (int j = 1; j < a.size(); ++j) {
      diff = min(diff, min(a[j] - a[j - 1], 24 - (a[j] - a[j - 1])));
    }
    ans = max(diff, ans);
  }
  cout << ans << endl;
}
