#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
struct Scc {
	int n;
	vector<vector<int>> g,
		rg;//逆向きのグラフ
	vector<int> cmp,//cmp[i]:頂点iが属する強連結成分の番号
		visited,
		num;//帰りがけ順で頂点が入る
	Scc(int N) {
		n = N;
		cmp.resize(n);
		visited.resize(n);
		g.resize(n);
		rg.resize(n);
	}
	void add_edge(int from, int to) {
		g[from].push_back(to);
		rg[to].push_back(from);
	}

	void dfs(int v) {
		visited[v] = true;
		for (int i = 0; i < g[v].size(); ++i) {
			if (!visited[g[v][i]])dfs(g[v][i]);
		}
		num.push_back(v);
	}

	void rdfs(int v, int k) {
		visited[v] = true;
		cmp[v] = k;
		for (int i = 0; i < rg[v].size(); ++i) {
			if (!visited[rg[v][i]])rdfs(rg[v][i], k);
		}
	}
	int calc() {
		for (int i = 0; i < n; ++i)visited[i] = false;
		num.clear();
		for (int i = 0; i < n; ++i) {
			if (!visited[i])dfs(i);
		}
		for (int i = 0; i < n; ++i)visited[i] = false;
		int k = 0;
		for (int i = num.size() - 1; i >= 0; --i) {
			if (!visited[num[i]]) {
				rdfs(num[i], k);
				++k;
			}
		}
		return k;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi d(n);
	REP(i, n)cin >> d[i];
	int mint = INF;
	REP(i, n) {
		mint = min(min(d[i], 24 - d[i]), mint);
	}
	RREP(t, mint + 1) {
		Scc scc(2 * n);
		REP(i, n) {
			FOR(j, i + 1, n) {
				if (abs(d[i] - d[j]) < t) {
					if (abs(d[i] + d[j] - 24) < t) {
						goto next;
					}
					else {
						scc.add_edge(i, n + j);
						scc.add_edge(j, n + i);
					}
				}
				if (abs(d[i] + d[j] - 24) < t) {
					scc.add_edge(i, j);
					scc.add_edge(j, i);
				}
			}
		}
		scc.calc();
		int f = 1;
		REP(i, n) {
			if (scc.cmp[i] == scc.cmp[n + i])f = 0;
		}
		if (f) {
			cout << t << endl;
			return 0;
		}
	next:;
	}
}
