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

long long N;
long long pos[100];
bool there[24];
long long ans = 0;


long long dfs(long long idx){
	if(idx == 24){
		vector<long long>vec;
		vec.push_back(0);
		for(long long i = 0; i < 24; i++){
			if(there[i]){
				vec.push_back(i);
			}
		}
		vec.push_back(24);

		long long tmp = INT_MAX;
		for(long long i = 0; i < vec.size() -1 ; i++){
			tmp = min(tmp, vec[i+1] - vec[i]);
		}
		ans = max(tmp, ans);
		return 0;
	}

	if(pos[idx] == 2){
		there[idx] = true;
		there[24-idx] = true;
		dfs(idx + 1);
		there[idx] = false;
		there[24-idx] = false;
		return 0;
	}else if(pos[idx] == 1){
		there[idx] = true;
		dfs(idx + 1);
		there[idx] = false;
		there[24-idx] = true;
		dfs(idx + 1);
		there[24-idx] = false;
		return 0;
	}else if(pos[idx] == 0){
		dfs(idx + 1);
	}else{
		exit(1);
	}
}


int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		pos[tmp]++;
		ans = min(ans, tmp);
	}
	if(pos[0] > 0){
			cout << 0 << endl;
			return 0;
	}

	for(long long i = 0; i <= 12; i++){
		if(pos[i] >= 3){
			cout << 0 << endl;
			return 0;
		}
	}

	dfs(0);
	cout << ans << endl;

}