#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a(13);
	a[0] = 1;
	for(Int i=0; i<n; ++i){
		Int d; cin >> d;
		++a[d];
	}
	if(a[0] >= 2 || a[12] >= 2 || [a](){
		Int res = 0;
		for(Int i=1; i<=11; ++i) res = max(res, a[i]);
		return res;
	}() >= 3){
		cout << 0 << "\n";
	}else{
		Int ans = 0;
		vector<Int> b(25);
		b[0] = b[24] = 1;
		if(a[12]) b[12] = 1;
		vector<Int> c;
		for(Int i=1; i<=11; ++i){
			if(a[i] == 1) c.push_back(i);
			if(a[i] == 2) b[i] = b[24-i] = 1;
		}
		for(Int i=0; i<(1<<c.size()); ++i){
			for(size_t j=0; j<c.size(); ++j){
				if((i>>j)&1) b[c[j]] = 1;
				else b[24-c[j]] = 1;
			}
			Int dif = 1e9;
			for(Int j=0; j<24; ++j)
				for(Int k=j+1; k<=24; ++k)
					if(b[j] & b[k])
						dif = min(dif, k-j);
			ans = max(ans, dif);
			for(size_t j=0; j<c.size(); ++j) b[c[j]] = b[24-c[j]] = 0;
		}
		cout << ans << "\n";
	}
}