#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> d(n), c(13,0);
	for(int i=0; i<n; i++){
		cin >> d[i];
		c[d[i]]++;
	}
	c[0]++;
	
	vector<bool> con(25, false);
	vector<int> nd;
	for(int i=0; i<13; i++){
		if(( (i==0||i==12)&&c[i]>1 ) || c[i]>2){
			cout << 0 << endl;
			return 0;
		}
		if(c[i]==2 || (c[i]==1&&(i==0||i==12))){
			con[i] = con[24-i] = true;
			c[i] = 0;
		}
		if(c[i]==1){
			nd.push_back(i);
		}
	}
	
	n = nd.size();
	int ans=0;
	if(n==0){
		int tmin = 100;
		int tmp=100;
		for(int j=0; j<24; j++){
			if(con[j]){
				tmin = min(tmin, tmp);
				tmp=1;
			}else{
				tmp++;
			}
		}
		ans = max(ans, tmin);
	}
	for(int i=0; i<(1<<n); i++){
		vector<bool> tcon = con;
		for(int j=0; j<n; j++){
			if((i&(1<<j))!=0){
				tcon[nd[j]] = true;
			}else{
				tcon[24-nd[j]] = true;
			}
		}
		int tmin = 100;
		int tmp=100;
		for(int j=0; j<25; j++){
			if(tcon[j]){
				tmin = min(tmin, tmp);
				tmp=1;
			}else{
				tmp++;
			}
		}
		ans = max(ans, tmin);
	}
	cout << ans << endl;

	return 0;
}