#include <bits/stdc++.h>
using namespace std;
int cnt[15];
int main() {
	int n;
	scanf("%d", &n);
	cnt[0] = 1;
	for (int i = 0; i < n; ++ i) {
		int x;
		scanf("%d", &x);
		cnt[x] ++;
	}
	vector<int> a, c;
	for (int i = 0; i <= 12; ++ i) {
		if (cnt[i] >= 3) return 0 * puts("0");
		if (cnt[i] == 2) {
			c.push_back(i);
			c.push_back(24 - i);
		}
		else if (cnt[i]) {
			a.push_back(i);
		}
	}
	int ans = 0;
	for (int mask = 0; mask < (1 << (int) a.size()); ++ mask) {
		vector<int> b = c;
		for (int i = 0; i < (int) a.size(); ++ i) {
			b.push_back((mask >> i & 1) ? a[i] : 24 - a[i]);
		}
		int s = 100;
		for (int i = 0; i < (int) b.size(); ++ i) {
			for (int j = i + 1; j < (int) b.size(); ++ j) {
				int t = abs(b[i] - b[j]);
				s = min(s, min(t, 24 - t));
			}
		}
		ans = max(ans, s);
	}
	printf("%d\n", ans);
}
