#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> d(n + 1);
	d[0] = 0;
	for (int i = 1; i <= n; ++i)cin >> d[i];
	sort(all(d));
	rep(i, n + 1)if (i % 2)d[i] = 24 - d[i];
	d.push_back(24);
	sort(all(d));
	int res = 12;
	rep(i, n + 1)
	{
		res = min(res, d[i + 1] - d[i]);
	}
	cout << res << endl;
}