#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1.01e9;
int main() {
  int n;
  while (cin >> n) {
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
      cin >> d[i];
    }
    if (n > 24) {
      cout << 0 << endl;
      continue;
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
      vector<int> cnt(24);
      for (int i = 0; i < n; i++) {
        if (mask & (1 << i)) {
          cnt[d[i]]++;
        } else {
          cnt[(24 - d[i]) % 24]++;
        }
      }
      cnt[0]++;
      int mn = INF;
      int last = -INF;
      for (int i = 0; i < 2 * 24; i++) {
        if (cnt[i % 24]) {
          if (cnt[i % 24] > 1) mn = 0;
          mn = min(mn, i - last);
          last = i;
        }
      }
      ans = max(ans, mn);
    }
    cout << ans << endl;
  }
  return 0;
}
