#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < n; i++)

int main() {

	int N;
	vector<int> D;
	vector<int> c(13);

	scanf("%d", &N);

	D.push_back(0);
	c[0]++;
	rep(i, N) {
		int t;
		scanf("%d", &t);
		D.push_back(t);
		c[t]++;
	}

	if (*max_element(c.begin(), c.end()) >= 3 || c[0] >= 2 || c[12] >= 2) {
		printf("0\n");
		return 0;
	}

	rep(i, 13) {
		if (c[i] == 2) {
			*find(D.begin(), D.end(), i) = 24 - i;
		}
	}

	sort(D.begin(), D.end());

	for (int i = 1; i <= 24 / (N + 1) + 10; i++) {

		int l = 0;
		for (int p = 0; p < D.size() - 1; p++) {
			if (D[p + 1] - D[p] < i) {
				D[p + 1] = 24 - D[p + 1];
				sort(D.begin(), D.end());
				p--;
				l++;
				if (l > 100) break;
			}
		}

		int s = 114514;
		for (int p = 0; p < D.size() - 1; p++) {
			s = min(s, D[p + 1] - D[p]);
		}

		s = min(s, 24 - *(D.end() - 1));

		if (s < i) {
			printf("%d\n", i - 1);
			return 0;
		}
	}

	return 0;
}