#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<ll> D(N + 10, 0), E(N + 10, 0);
  for (ll i = 1; i <= N; i++) cin >> D[i];
  for (ll i = 1; i <= N; i++) E[i] = (24 - D[i]) % 24;
  ll x = 12, y = 12;
  for (ll i = 0; i < N; i++) {
    ll a, b, c, d;
    (a = abs(D[i] - D[i + 1])) %= 12;
    (b = abs(D[i] - E[i + 1])) %= 12;
    (c = abs(E[i] - D[i + 1])) %= 12;
    (d = abs(E[i] - E[i + 1])) %= 12;
    x = min(x, max(a, c));
    y = min(y, max(b, d));
  }
  ll ans = max(x, y);
  cout << ans << endl;
}
