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

int main()
{
	int N;
	cin >> N;
	if (N >= 24) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> D(N), cnt(13);
	for (int i = 0; i < N; i++) {
		cin >> D[i];
		cnt[D[i]]++;
	}
	sort(D.begin(), D.end());
	if (N >= 12) {
		bool dis = cnt[0] == 0;
		for (auto val : cnt) {
			if (val > 2) {
				dis = false;
			}
		}
		cout << dis << endl;
		return 0;
	}
	int res = 0;
	for (int i = 0; i < (1 << N); i++) {
		vector<int> t(N + 1);
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				t[j] = D[j];
			}
			else {
				t[j] = 24 - D[j];
			}
		}
		int ans = 24;
		for (int j = 0; j < N; j++) {
			for (int k = j + 1; k <= N; k++) {
				int d = abs(t[j] - t[k]) % 24;
				ans = min(ans, min(d, 24 - d));
			}
		}
		res = max(res, ans);
	}
	cout << res << endl;
	return 0;
}
