#include<bits/stdc++.h>
using namespace std;
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto & e : v) cin >> e;
    array<float,13> cnt = {0};
    cnt[0]++;
    for(auto  e : v)cnt[e]++;
    for(auto  e : cnt) if(e >= 3) return puts("0") * 0;
    if(cnt[0] >= 2 or cnt[12] >= 2) return puts("0")* 0;
  
    vector<int>base(25,0LL);
    base[0] = 1;
    for(int i = 1; i <= 12; ++i){
        if(cnt[i] == 1){
            //???
        } else if(cnt[i] == 2){
            base[i] = base[ 24 - i] = 1;
        }
    }
    int ans = -INF;
    for(int bit = 0; bit < (1LL << 12); ++bit){
        vector<int>tbase = base;
        for(int i = 1; i <= 12; ++i){
            if(cnt[i] == 1){
                ((bit & (1LL << (i - 1))) >= 1 ? tbase[i] : tbase[24 - i]) = 1;
            }
        }
        int tans = INF;
        for(int i = 0; i < tbase.size(); ++i){
            for(int j = 0; j < tbase.size(); ++j){
                if(i != j and tbase[i] != 0 and tbase[j] != 0)
                    cmin(tans,min(max(i,j) - min(i,j),24 - (max(i,j) - min(i,j))));
            }
        }
        cmax(ans, tans);
    }
    cout << ans << endl;
}
