#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int D[57];
    cin >> N;
    D[0]=0;
    REP(i,N){
        cin >> D[i+1];
    }
    int Ans=INF;
    sort(D,D+N+1);
    REP(i,N+1){
        if(i%2==1)D[i]=24-D[i];
        if(D[i]==24)D[i]=0;
        //cout << D[i] << endl;
    }
    REP(i,N+1){
        REP(j,N+1){
            if(i==j)continue;
            int d=abs(D[i]-D[j]);
            Ans=min(Ans,d);
            Ans=min(Ans,24-d);
        }
    }
    cout << Ans << endl;
    return 0;
}

