#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int D[55],N;
string s;
int s1,s2;
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>D[i];
    }
    D[N]=0;
    sort(D,D+N+1);

    REP(i,0,N+1){
        if(i%2){
            D[i]=(24-D[i])%24;
        }
    }
    
    int mn=23;
    REP(i,0,N+1) REP(j,i+1,N+1){
        int d = abs(D[i]-D[j]);
        mn=min(mn,min(d,24-d));
    }
    p(mn);
	return 0;
}
