#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> c(25);
	c[0] = 1;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		c[x]++;
	}
	c[24] = c[0];
	int p = 0;
	for(int i = 1; i <= 11; i++){
		if(c[i] >= 1){
			c[24 - i] = (c[i] + 1 - p) / 2;
			c[i] = (c[i] + p) / 2;
			p = 1 - p;
		}
	}
	int t = 1, ans = 24;
	for(int i = 1; i <= 24; i++){
		if(c[i] >= 2){
			ans = 0;
			break;
		}else if(c[i] == 1){
			ans = min(ans, t);
			t = 1;
		}else{
			t++;
		}
	}
	cout << ans << endl;
	return 0;
}
