#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
 

void solve(){
   int n;
   cin>>n;
   int d,ans=0,mmin=24;
   map<int,int>mp;
   rep(i,n){
       cin>>d;
       if(d==0){
           cout<<0<<"\n";
           return;
       }
       mmin=min(mmin,d);
       mp[d]++;
   }
   vector<int>v;
   if(n>24){
       cout<<0<<"\n";
       return 0;
   }
   for(auto x:mp){
       if(x.second>2){
           cout<<0<<"\n";
           return;
       }
       rep(i,x.second)v.pb(x.first);
   }
   for(auto x:mp){
       if(x.first==1){
           cout<<1<<"\n";
           return;
       }
   }
   v.pb(0);
   vector<int>w(n+1);
   for(int i=0;i<(1<<n);++i){
       rep(j,n+1){
           if((1<<j)&i)w[j]=24-v[j];
           else w[j]=v[j];
       }
       int minv=30;
       rep(j,n){
           for(int k=j+1;k<n+1;++k){
               minv=min(minv,abs(w[j]-w[k]));
           }
       }
       ans=max(ans,minv);
   }
   cout<<min(mmin,ans)<<"\n";
}
 
 
signed main(){
	ios::sync_with_stdio(false);
        cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}