
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector<int>D;

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int d; cin >> d;
		D.push_back(d);
	}
	D.push_back(0);
	N++;
	int a[13] = {};
	for (int i = 0; i < N; ++i) {
		a[D[i]]++;
	}
	for (int i = 0; i <= 12; ++i) {
		if (a[i] >= 3) {
			cout << "0\n";
			return 0;
		}
	}
	int ans = 0;
	for (int B = 0; B < (1 << 13); ++B) {
		vector<int>vec;
		for (int i = 0; i <= 12; ++i) {
			if (a[i] == 0) {
				continue;
			}
			if (a[i] == 1) {
				int day = i;
				if (B & (1 << i))day = 24 - i;
				day %= 24;
				vec.push_back(day);
			}
			else {
				vec.push_back(i);
				vec.push_back((24 - i) % 24);
			}
		}
		sort(vec.begin(), vec.end());
		vec.push_back(vec[0] + 24);
		int small = 114514;
		for (int i = 1; i < vec.size(); ++i) {
			small = min(small,
				abs(vec[i] - vec[i - 1]));
		}
		ans = max(ans, small);
	}
	cout << ans << endl;
	return 0;
}
