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

int main(){
	int n,cnt[13] = {},ma = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int d;
		cin >> d;
		cnt[d]++;
	}
	cnt[0]++;
	for(int i = 0;i <= 12;i++){
		if(cnt[i] >= 3){
			cout << 0 << endl;
			return 0;
		}
	}
	for(int i = 0;i < (1 << 13);i++){
		int mi = 30;
		vector<int> vec;
		for(int j = 0;j < 13;j++){
			if(!cnt[j]) continue;
			if(cnt[j] == 2 || ((i >> j) & 1)) vec.push_back(j);
			if(cnt[j] == 2 || !((i >> j) & 1)) vec.push_back(24 - j);
		}
		for(int j = 0;j < vec.size();j++){
			for(int k = j + 1;k < vec.size();k++) mi = min(mi,min(abs(vec[j] - vec[k]),24 - abs(vec[j] - vec[k])));
		}
		ma = max(ma,mi);
	}
	cout << ma << endl;
	return 0;
}