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

int main() {
	int n, d[50];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	int u = 0, v = 0, r = 12;
	for (int i = 0; i < n - 1; i++) {
		if (u <= v) {
			r = min(r, d[i] - u);
			u = d[i];
		} else {
			r = min(r, d[i] - v);
			v = d[i];
		}
	}
	r = min(r, max(min(d[n - 1] - u, 24 - v - d[n - 1]), min(d[n - 1] - v, 24 - u - d[n - 1])));
	cout << r << endl;
	return 0;
}
