#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int d[50];

int ans;


int dist(int b){
	int res=INF;

	for (int i=1;i<=12;i++){
		if (b&b<<i){
			res=i;
			break;
		}
	}
	for (int i = 1; i < res; i++){
		if (b&(b>>24-i)){
			res = i;
			break;
		}
	}

	
	return res;
}

void search(int b,int i){
	if (i==n){
		ans = max(ans, dist(b));
		return;
	}
	if (ans >= dist(b)){
		return;
	}
	if ((b&(1 << d[i]))==0) search(b | 1 << (d[i]), i + 1);
	if(d[i] && (b&(1<<24-d[i]))==0) search(b | 1 << (24-d[i]), i + 1);
}



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


	cin>>n;
	rep(i, n)cin >> d[i];
	ans = 0;

	search(1, 0);

	cout << ans << endl;

	return 0;
}