#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int n;
int d[53];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d, d + n);
	for (int i = 1; i < n; i += 2) d[i] = 24 - d[i];
	int ans = d[0];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) continue;
			ans = min(ans, (int)abs(d[i] - d[j]));
		}
	}
	cout << ans << endl;
	return 0;
}