# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int n,v[50];
int nowmin = 0;
void f(bitset<50> b, int p) {
	if (n == 1)nowmin = v[0];
	if (p == n - 1) {
		vector<int>vv;
		TFOR(i, n)vv.push_back(b[i] ? 24 - v[i] : v[i]); 
		sort(ALL(vv));
		int minn = vv[0];
		TFOR(i, n) {
			for (int j = 1 + i; j < n; ++j) {
				if (abs(vv[i] - vv[j]) < minn)minn = abs(vv[i] - vv[j]);
			}
		}
		nowmin = max(nowmin, minn);
	}
	else {
		f(b, p + 1);
		bitset<50>b2=b;
		b2[p] = 1;
		f(b2, p + 1);
	}
}
int main() {
	bitset<50>b = {};
	cin >> n;
	int ct[12] = {};
	int m = 0;
	TFOR(i, n) { cin >> v[i]; ct[v[i] - 1]++; if (ct[v[i] - 1] == 3) { cout << 0 << endl; return 0; }if (ct[v[i] - 1] == 2 && m < v[i] - 1)m = v[i] - 1; }
	sort(v, v + n);
	if (m != 0) {
		m += 1;
		if (m >= 6)cout << 24 - m * 2 << endl;
		else cout << v[0] << endl;
		return 0;}
	
	f(b, 0);
	cout << nowmin << endl;
	return 0;
}# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int n,v[50];
int nowmin = 0;
void f(bitset<50> b, int p) {
	if (n == 1)nowmin = v[0];
	if (p == n - 1) {
		vector<int>vv;
		TFOR(i, n)vv.push_back(b[i] ? 24 - v[i] : v[i]); 
		sort(ALL(vv));
		int minn = vv[0];
		TFOR(i, n) {
			for (int j = 1 + i; j < n; ++j) {
				if (abs(vv[i] - vv[j]) < minn)minn = abs(vv[i] - vv[j]);
			}
		}
		nowmin = max(nowmin, minn);
	}
	else {
		f(b, p + 1);
		bitset<50>b2=b;
		b2[p] = 1;
		f(b2, p + 1);
	}
}
int main() {
	bitset<50>b = {};
	cin >> n;
	int ct[12] = {};
	int m = 0;
	TFOR(i, n) { cin >> v[i]; ct[v[i] - 1]++; if (ct[v[i] - 1] == 3) { cout << 0 << endl; return 0; }if (ct[v[i] - 1] == 2 && m < v[i] - 1)m = v[i] - 1; }
	sort(v, v + n);
	if (m != 0) {
		m += 1;
		if (m >= 6)cout << 24 - m * 2 << endl;
		else cout << v[0] << endl;
		return 0;}
	
	f(b, 0);
	cout << nowmin << endl;
	return 0;
}