#include <bits/stdc++.h>
using namespace std;
int n,a[50],b[50],c[50],ans,x,A[30],t;
void dfs(int x){
	if (x==n+1){
		t=n;
		for (int i=1;i<=n;++i) c[i]=a[i];
		for (int i=0;i<13;++i) if (A[i]==2) c[++t]=-i,c[++t]=i;
		sort(c+1,c+t+1); x=24+c[1]-c[t];
		for (int i=1;i<t;++i) x=min(x,c[i+1]-c[i]);
		ans=max(x,ans); return;
	}
	a[x]=-b[x];
	dfs(x+1);
	a[x]=b[x];
	dfs(x+1);
}
int main(){
	scanf("%d",&n); A[0]=1;
	for (int i=1;i<=n;++i) scanf("%d",&x),++A[x];
	for (int i=0;i<13;++i)
	if (A[i]>2){puts("0"); return 0;}
	n=0;
	for (int i=0;i<13;++i) if (A[i]==1) b[++n]=i;
	dfs(1);
	printf("%d\n",ans);
	return 0;
}