#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int N;
int num[13];

int rec(int i, int bit)
{
	if (i == 13) {
		int ret = iinf;
		int d = iinf;
		for (int j = 0; j < 48; j++) {
			if (bit & (1 << (j % 24))) {
				ret = min(ret, d);
				d = 0;
			}
			d++;
		}
		return ret;
	}

	switch(num[i]) {
		case 0:
			return rec(i + 1, bit);
		case 1:
			return max(rec(i + 1, bit | (1 << i)), rec(i + 1, bit | (1 << (24 - i))));
		case 2:
			return rec(i + 1, bit | (1 << i) | (1 << (24 - i)));
	}
	return 0;
}

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	num[0]++;
	for (int i = 0; i < N; i++) {
		int m; scanf("%d", &m);
		num[m]++;
		if (num[m] >= 3 || m == 0) {
			printf("0\n");
			return 0;
		}
	}

	printf("%d\n", rec(1, 1));

	return 0;
}
