#include <bits/stdc++.h>
using namespace std;
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])));
    }
    ans = max(diff, ans);
  }
  cout << ans << endl;
}
