#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

ll N;
ll ans = 0;

void solve() {
    cin >> N;
    ll D[N];
    rep(i,N) cin >> D[i];
    rep(mask,1 << 24) {
        int used[N] = {};
        int g = 1;
        rep(j,24) {
            if ((mask >> j) & 1) {
                int f = 0;
                rep(k,N) {
                    if (used[k]) continue;
                    if (j == D[k] || j == 24 - D[k]) {
                        used[k] = 1;
                        f = 1;
                    }
                    if (f) break;
                }
                if (!f) {
                    g = 0;
                    break;
                }
            }
        }
        rep(i,N) if (!used[i]) g = 0;
        if (g) {
            ll l = -1;
            ll itv = 100;
            rep(j,24) {
                //cout << ((mask >> j) & 1);
                if ((mask >> j) & 1) {
                    if (l == -1) {
                        l = j;
                    } else {
                        itv = min(j - l, itv);
                        l = j;
                    }
                }
            }
            //cout << endl;
            if (itv != 100)
                ans = max(ans, (ll)itv);
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    solve();
    return 0;
}
