#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> d(n);
	for(int i = 0; i < n; i++) scanf("%d", &d[i]);

	std::vector<int> vec(13); vec[0]++;
	for(auto e: d) vec[e]++;

	for(auto e: vec) {
		if(e < 3) continue;
		printf("0\n");
		return 0;
	}

	std::vector<int> free;
	std::vector<int> latte;
	for(int i = 0; i < 13; i++) {
		if(!vec[i]) continue;
		if(vec[i] == 1) free.push_back(i);
		if(vec[i] == 2) {
			latte.push_back(i);
			latte.push_back(24 - i);
		}
	}

	int ans = 0;
	for(int i = 0; i < (1 << free.size()); i++) {
		std::vector<int> malta = latte;

		for(int j = 0; j < free.size(); j++) {
			if(i >> j & 1) malta.push_back(free[j]);
			else malta.push_back(24 - free[j]);
		}

		int tmp = 1 << 30;
		for(int j = 0; j < malta.size(); j++)
			for(int k = j + 1; k < malta.size(); k++)
				tmp = std::min(tmp, std::abs(malta[j] - malta[k]) % 24);
		ans = std::max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}
