#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int N;
int D[55];
int seq[55];
int val[55];
int num[55];
int res=0;

bool cmp(int aa, int bb)
{
	if(val[aa]<val[bb])
		return true;
	else
		return false;
}

int srch(int dep)
{
	if(dep==N+1)
		return 50;
	int i = seq[dep];
	int mn;
	int tmp;
	if(num[i]==-1 && num[i+1]==-1){
		num[i] = D[i];
		num[i+1] = 24-D[i+1];
		mn = num[i+1]-num[i];
		if(mn<0)
			mn = -mn;
		if(mn>=12)
			mn = 24-mn;
		tmp = srch(dep+1);
		if(mn > tmp)
			mn = tmp;
		int tmn = mn;
		num[i] = 24-D[i];
		num[i+1] = D[i+1];
		mn = num[i+1]-num[i];
		if(mn<0)
			mn = -mn;
		if(mn>=12)
			mn = 24-mn;
		tmp = srch(dep+1);
		if(mn > tmp)
			mn = tmp;
		if(tmn > mn)
			mn = tmn;
		num[i] = -1;
		num[i+1] = -1;
	}
	else if(num[i]==-1){
		if(num[i+1]>=12)
			num[i] = D[i];
		else
			num[i] = 24-D[i];
		mn = num[i+1]-num[i];
		if(mn<0)
			mn = -mn;
		if(mn>=12)
			mn = 24-mn;
		tmp = srch(dep+1);
		if(mn > tmp)
			mn = tmp;
		num[i] = -1;//
	}
	else if(num[i+1]==-1){
		if(num[i]>=12)
			num[i+1] = D[i+1];
		else
			num[i+1] = 24-D[i+1];
		mn = num[i+1]-num[i];
		if(mn<0)
			mn = -mn;
		if(mn>=12)
			mn = 24-mn;
		tmp = srch(dep+1);
		if(mn > tmp)
			mn = tmp;
		num[i+1] = -1;
	}
	else{
		mn = num[i+1]-num[i];
		if(mn<0)
			mn = -mn;
		if(mn>=12)
			mn = 24-mn;
		tmp = srch(dep+1);
		if(mn > tmp)
			mn = tmp;
	}
	//if(mn < val[i])
	//	mn = val[i];
	return mn;
}

void solve()
{
	int i;
	res = 0;
	D[N] = 0;
	sort(D, D+N+1);
	for(i=0; i<N; i++)
		seq[i] = i;
	for(i=0; i<N; i++)
		val[i] = D[i+1]-D[i];
	sort(seq, seq+N, cmp);
	for(i=0; i<N+1; i++)
		num[i] = -1;
	res = srch(0);
	printf("%d\n", res);
}

int res2;
void solve2()
{
	int i, j;
	res2 = 0;
	int vv[20];
	for(i=0; i<(1<<(N+1)); i++){
		for(j=0; j<N+1; j++){
			if( (i & (1<<j) ) > 0)
				vv[j] = D[j];
			else
				vv[j] = 24-D[j];
		}
		int mn=50;
		for(j=0; j<N; j++){
			int tmp = vv[j+1]-vv[j];
			if(tmp<0)
				tmp = -tmp;
			if(tmp>=12)
				tmp = 24-tmp;
			if(mn > tmp)
				mn = tmp;
		}
		if(res2 < mn)
			res2 = mn;
	}
}

int res3;
int a[55];
int a2[55];
int aL, a2L;
void solve3()
{
	int i, j;
	res3 = 0;
	D[N] = 0;
	sort(D, D+N+1);
	int c3[20];
	for(i=0; i<=12; i++)
		c3[i] = 0;
	for(i=0; i<N+1; i++){
		c3[D[i]] ++;
	}
	for(i=0; i<=12; i++){
		if(c3[i]>2)
			break;
	}
	if(i<=12){
		printf("0\n");
		return ;
	}
	if(c3[0]>1){
		printf("0\n");
		return ;
	}
	aL = 0;
	for(i=0; i<=12; i++){
		if(c3[i]==2){
			a[aL] = i;
			aL ++;
			a[aL] = 24-i;
			aL ++;
		}
	}
	a2L = 0;
	for(i=0; i<=12; i++){
		if(c3[i]==1){
			a2[a2L] = i;
			a2L ++;
		}
	}
	int vv[20];
	for(i=0; i<(1<<(a2L)); i++){
		for(j=0; j<a2L; j++){
			if( (i & (1<<j) ) > 0)
				vv[j] = a2[j];
			else
				vv[j] = 24-a2[j];
		}
		int v3[55];
		for(j=0; j<aL; j++){
			v3[j] = a[j];
		}
		for(j=0; j<a2L; j++){
			v3[aL+j] = vv[j];
		}
		int l = aL+a2L;
		int i2, j2;
		int mn=50;
		int tmp;
		for(i2=0; i2<l; i2++){
			for(j2=i2+1; j2<l; j2++){
				tmp = v3[j2] - v3[i2];
				if(tmp<0)
					tmp = -tmp;
				if(tmp>=12)
					tmp = 24-tmp;
				if(tmp<mn)
					mn = tmp; 
			}
		}
		if(res3 < mn)
			res3 = mn;
	}
	printf("%d\n", res3);
}

void test1()
{
	int i;
	N = 10;
	for(i=0; i<N; i++){
		do{
			D[i] = rand() % 13;
		}while(D[i]==0);
	}
	solve();
	solve3();
	if(res != res3)
		printf("Wrong\n");
}

void test()
{
	int i;
	for(i=0; i<1000; i++)
		test1();
}

int main()
{
	//test();
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &D[i]);
	solve3();
	return 0;
}

Measured memory_bytes: 128