#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int main() {
  int n;
  cin >> n;
  vector<int> d(n + 1);
  for (int i = 0; i < n; i++) cin >> d[i];
  d[n] = 0;
  int ans = 0;
  for (int bit = 0; bit < (n / 2); bit++) {
    set<int> st;
    for (int i = 0; i < (n / 2); i++) {
      if (bit & i) {
        st.insert(24 - d[i]);
      } else {
        st.insert(d[i]);
      }
    }
    for (int i = n / 2; i < n; i++) {
      int maxgap = 100;
      int maxgapr = 100;
      for (auto j : st) {
        maxgap = min(maxgap, abs(j - d[i]));
        maxgapr = min(maxgapr, abs(j - (24 - d[i])));
      }
      if (maxgap >= maxgapr) {
        st.insert(d[i]);
      } else {
        st.insert(24 - d[i]);
      }
    }
    int pre = -1;
    int num = 100;
    for (auto i : st) {
      if (pre != -1) {
        num = min(num, i - pre);
      }
      pre = i;
    }
    ans = max(ans, num);
  }
  cout << ans << endl;
}
