#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
void YN(bool flag) { cout << ((flag) ? "YES" : "NO") << endl; }
void Yn(bool flag) { cout << ((flag) ? "Yes" : "No") << endl; }
void yn(bool flag) { cout << ((flag) ? "yes" : "no") << endl; }
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < int(N); i++) cin >> D[i];
  if (N >= 24) {
    cout << 0 << endl;
  }
  int ans = 0;
  for (int i = 0; i < int(1 << N); i++) {
    int cnt = 30;
    vector<int> t(24, 0);
    for (int j = 0; j < int(N); j++)
      t[(((i & 1 << j) ? D[j] : 24 - D[j])) % 24]++;
    for (int j = 0; j < int(24); j++)
      if (t[j] > 1) cnt = 0;
    int now = 0;
    for (int j = 0; j < int(24); j++) {
      if (t[j]) {
        int d = j - now;
        d = min(d, 24 - d);
        cnt = min(cnt, d);
        now = j;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
