#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    int N; cin>>N;
    vector<int> cnt(13);
    cnt[0]++;
    for(int i=0;i<N;i++){
	int d; cin>>d;
	cnt[d]++;
    }

    if(cnt[0]>1 or cnt[12]>1){
	cout<<0<<endl;
	return 0;
    }
    for(int i=1;i<=11;i++){
	if(cnt[i]>2){
	    cout<<0<<endl;
	    return 0;
	}
    }

    int ans=0;
    const int K=11;
    for(int S=0;S<(1<<K);S++){
	vector<int> v;
	for(int i=0;i<cnt[0];i++) v.push_back(0);
	for(int i=0;i<cnt[12];i++) v.push_back(12);
	for(int i=0;i<K;i++){
	    if(cnt[i+1]==0) continue;
	    if(cnt[i+1]==1){
		if(S>>i&1) v.push_back(i+1);
		else v.push_back(24-(i+1));
	    }else{
		v.push_back(i+1);
		v.push_back(24-(i+1));
	    }
	}
	v.push_back(24);
	sort(v.begin(),v.end());
	int min_diff=1e9;
	for(int i=0;i+1<v.size();i++){
	    min_diff=min(min_diff,v[i+1]-v[i]);
	}
	ans=max(ans,min_diff);
    }
    cout<<ans<<endl;
}
