#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	int D[15] = {}; 
	D[0] = 1; 
	cin >> N; 
	for(int i = 0; i < N; i++){
		int a; cin >> a; D[a] ++; 
	}
	int ans = 12; 
	for(int i = 1; i < 12; i++){
		if(D[i] >= 3) ans = 0; 
	}
	if(D[0] >= 2) ans = 0; 
	if(D[12] >= 2) ans = 0; 
	if(ans > 0){
		vector<int> exist = {0, 24};  
		for(int i = 1; i < 12; i++){
			if(D[i] == 2){
				exist.push_back(i); 
				exist.push_back(24 - i); 
			}
			else if(D[i] == 1){
				if(exist.at(exist.size()-1) < 12){
					exist.push_back(24 - i); 
				}
				else{
					exist.push_back(i); 
				}
			}
		}
		if(D[12] == 1) exist.push_back(12); 
		sort(exist.begin(), exist.end()); 
		for(int j = 0; j < exist.size() - 1; j++){
			ans = min(ans, exist[j+1] - exist[j]); 
		}
 	}
	cout << ans << endl; 
}