#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	a.push_back(0);
	sort(a.begin(), a.end());
	rep(i, 0, n + 1) {
		if (i % 2) a[i] = 24 - a[i];
	}
	int ans = 24;
	rep(i, 0, n + 1)rep(j, i+1, n + 1) {
		int d = abs(a[i] - a[j]);
		ans = min({ ans,d,24 - d });
	}
	printf("%d", ans);
	return 0;
}
