#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,d[52]={},dr[52]={},i,j,k,sm1=24,sm2=24,sm3=24,smax=0;
	cin>>n;
	FOR(i,1,n+1){
		cin>>d[i];
	}
	n++;
	sort(d,d+n);
	FOR(i,0,n)dr[i]=24-d[i];
	int f=0,s1,s2,s3;
	FOR(i,1,n){
		//cout<<d[i]<<" "<<dr[i]<<endl;
		if(f==0){
			s1=d[i]-dr[i-1];
			s2=dr[i]-d[i-1];
			if(s1>12||s1<-12)s1=d[i]-d[i-1];
			if(s2>12||s2<-12)s2=d[i]-d[i-1];
		}else{
			s2=d[i]-dr[i-1];
			s1=dr[i]-d[i-1];
			if(s1>12||s1<-12)s1=d[i]-d[i-1];
			if(s2>12||s2<-12)s2=d[i]-d[i-1];
		}
		if(n>=2){
			s3=d[i]-dr[i-2];
		}
		if(s1<0)s1=-s1;
		if(s2<0)s2=-s2;
		if(sm1>s1)sm1=s1;
		if(sm2>s2)sm2=s2;
		if(sm1>s3)sm1=s3;
		if(sm2>s3)sm2=s3;
		f=(f+1)%2;
	}
	//sm1=sm1%12;
	//sm2=sm2%12;
	smax=sm1>sm2?sm1:sm2;
	if(n==2)smax=d[1];
	FORQ(i,1,12){
		if(upper_bound(d.begin(), d.begin()+n-1, i)-lower_bound(d.begin(), d.begin()+n-1, i)>=3)smax=0;
	}
	cout<<smax<<endl;
    return 0;
}
