#include <bits/stdc++.h>
using namespace std;

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

signed main() {
  int n;
  cin >> n;

  int d[1010] = {};
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
  }

  if (n >= 24) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  int a[100];
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        a[j] = d[j];
      } else {
        a[j] = 24 - d[j];
      }
    }
    sort(a, a + n);
    int diff = min(24 - a[n - 1], a[n - 1]);
    for (int i = 1; i < n; ++i) {
      diff = min(diff, min(a[i] - a[i - 1], 24 - (a[i] - a[i - 1]));
    }

    // int diff = 1001001;
    // for (int j = 0; j <= n; ++j) {
    //   for (int k = 0; k <= n; ++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;
}
