#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn = 50 + 10;
const int inf = 1 << 30;
int n, D[maxn][3], table[13], timeGap[maxn], ans;
int getMin(){
	int minimum = inf;
	for(int i = 0; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			int Gap = abs(timeGap[i] - timeGap[j]);
			Gap = min(Gap, 24 - Gap);
			minimum = min(minimum, Gap);
		}
	}
	// cout << "ans:";
	// for(int i = 0; i <= n; i++){
	// 	cout << timeGap[i] << " ";
	// }
	// cout << endl;
	return minimum;
}
void dfs(int k){
	for(int i = 1; i <= D[k][0]; i++){
		timeGap[k] = D[k][i];
		if(k == n){
			int minimum = 0;
			minimum = getMin();
			ans = max(ans, minimum);
		}
		else dfs(k + 1);
	}
}
int main(){
	//freopen("input.txt", "r", stdin);
	while(scanf("%d", &n) != EOF){
		int flag = 0;
		ans = -inf;
		memset(table, 0, sizeof(table));
		D[0][0] = 1;
		D[0][1] = 0;
		table[0]++;
		for(int i = 1; i <= n; i++){
			int temp = 0;
			scanf("%d", &temp);
			D[i][0] = 2;
			D[i][1] = temp;
			D[i][2] = 24 - temp;
			if(temp == 12) D[i][0] = 1;
			table[temp]++;
			if(table[temp] == 3) flag = 1;
		}
		if(!flag){
			for(int i = 0; i <= 12; i++){
				if(table[i] == 2){
					int p1 = 0, p2 = 0;
					for(int j = 1; j <= n; j++){
						if(D[j][1] == i && !p1) p1 = j;
						else if(D[j][1] == i && p1) {p2 = j; break;}
					}
					D[p1][0] = 1;
					D[p2][0] = 1;
					D[p2][1] = 24 - i;
				}
			}
			// for(int i = 0; i <= n; i++){
			// 	printf("%d %d %d\n", D[i][0], D[i][1], D[i][2]);
			// }
			dfs(0);
			printf("%d\n", ans);
		}
		else{
			printf("0\n");
		}	

	}
	return 0;
}