#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, a[60];
signed main() {
	cin >> n; for1(i, n)cin >> a[i];
	sort(a, a + n + 1);
	if (a[1] == 0) { cout << "0\n"; return 0; }
	for (int i = 2; i <= n; i += 2)a[i] = 24 - a[i];
	sort(a, a + n + 1);
	int ans = 24;
	for1(i, n)ans = min(ans, a[i] - a[i - 1]);
	cout << ans << endl;
}