#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, ans;

int main()
{
	in >> N;
	std::vector<int>D(N);
	rep(i, N) in >> D[i];
	D.push_back(0); ++N;
	std::sort(D.begin(), D.end());
	rep(i, N)
	{
		if (i % 2) D[i] = 24 - D[i];
	}
	ans = 24;
	rep(i, N)
	{
		rep(j, N)
		{
			if (i == j) continue;
			auto d = abs(D[i] - D[j]);
			ans = std::min(ans, std::min(d, 24 - d));
		}
	}
	out << ans << std::endl;
	return 0;
}
