#include<iostream>
#include<cstring>
using namespace std;

int main(){
	int n;
	int i,j,k;
	int d[15];
	int s=12;
	memset(d,0,sizeof(d));
	cin>>n;
	for(i=0;i<n;i++){
		cin>>k;
		d[k]++;
	}
	int a=0,b=0;
	for(i=0,j=0;i<=12;i++){
		if(d[i]==0)continue;
		if(d[i]>2)s=0;
		else if(d[i]==2){
			if(s>i-b)s=i-b;
			b=i;
			if(s>a+i)s=a+i;
			a=-i;
		}else if(j%2==0){
			if(s>i-b)s=i-b;
			b=i;
		}else{
			if(s>a+i)s=a+i;
			a=-i;
		}
		j++;
	}
	a+=24;
	if(s>a-b)s=a-b;
	cout<<s<<endl;
	return 0;
}
