#include <algorithm>
#include <iostream>
#include <vector>
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;
  scanf("%d", &n);

  int d[51] = {};
  for (int i = 0; i < n; ++i) {
    scanf("%d", d + i);
  }

  // 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);
    int a[50] = {};
    for (int j = 0; j < n; ++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])));
    //   }
    // }

    // sort(all(a));
    sort(a, a + n + 1);
    int diff = min(a[n - 1]], 24 - a[n - 1]]);
    for (int j = 1; j <= n; ++j) {
      diff = min(diff, min(a[j] - a[j - 1], 24 - (a[j] - a[j - 1])));
    }
    // for (int j = 0; j < a.size(); ++j) {
    //   cout << a[j] << " ";
    // }
    // cout << " : " << diff << endl;

    ans = max(diff, ans);
  }

  cout << ans << endl;
}
