#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int d[60];
bool dp[2][1<<24];
int main(){
	int n;scanf("%d",&n);
	int Max=0;
	rep(i,n){
		scanf("%d",&d[i]);
	}
	dp[1][0]=true;
	rep(i,n){
		rep(j,1<<24)dp[i%2][j]=false;
		rep(j,1<<24){
			if(dp[!(i%2)][j]==false)continue;
			if(!(j>>d[i]&1))dp[i%2][j|1<<d[i]]=true;
			if(d[i]&&!(j>>(24-d[i])&1))dp[i%2][j|1<<(24-d[i])]=true;
		}
	}
	rep(i,1<<24){
		if(!dp[!(n%2)][i])continue;
		vector<int>v;
		rep(j,24){
			if(i>>j&1)v.push_back(j);
		}
		int sum=INT_MAX;
		rep(i,v.size()){
			sum=min(sum,d[i]);
			if(n>1){
				if(i<v.size()-1){
					int A=v[i+1]-v[i];
					sum=min({sum,A,24-A});
				}
				else{
					int A=v.back()-v.front();
					sum=min({sum,A,24-A});
				}
			}
		}
		Max=max(Max,sum);
	}
	cout<<Max<<endl;
}