#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

//-----------------------------------------------------------------------------

int n;
int d[51],cnt[51][51];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n;
	REP(i,n) cin>>d[i+1];

	sort(d,d+n+1);

	FOR(i,1,n+1) {
		if(!(i&1)) d[i]=24-d[i];
	}

	int mi=INF;
	FOR(i,1,n+1) {
		int x=abs(d[i]-d[i-1]);
		if(i==1) mi=d[i];
		else mi=min(min(mi,abs(d[i]-d[i-2])),min(x,24-x));
	}

	cout<<mi<<endl;

	return 0;
}
