#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 60;
const int INF = 1e9;
int n;
int a[N], b[N];

inline int cal(int x, int y)
{
	if (x < y) swap(x, y);
	int d = x-y;
	return min(d, 24-d);
}

inline bool check(int x)
{
	int mi = INF;
	b[0] = 0;
	for (int i = 1; i <= n; i ++){
		b[i] = a[i];
		for (int j = 0; j < i; j ++){
			if (cal(a[i], b[j]) < x){
				b[i] = 24-a[i];
				break;
			}
		}
	}
	sort(b, b+1+n);
	for (int i = 1; i <= n; i ++)
		for (int j = 0; j < i; j ++){
			mi = min(mi, cal(b[i], b[j]));
		}
	if (mi >= x) return true;
	
	mi = INF;
	b[0] = 24;
	for (int i = 1; i <= n; i ++){
		b[i] = a[i];
		for (int j = 0; j < i; j ++){
			if (cal(a[i], b[j]) < x){
				b[i] = 24-a[i];
				break;
			}
		}
	}
	sort(b, b+1+n);
	for (int i = 1; i <= n; i ++)
		for (int j = 0; j < i; j ++){
			mi = min(mi, cal(b[i], b[j]));
		}
	return mi >= x;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
	}
	sort(a, a+1+n);
	for (int i = 12; i >= 0; i --){
		if (check(i)){
			printf("%d\n", i);
			return 0;
		}
	}
}