from copy import copy
import sys
from collections import Counter
n = int(input())
d = sorted(list(map(int, input().split())))
if d[0] == 0:
	print(0)
	sys.exit()
c = Counter(d)
if max(c.values()) >= 3:
	print(0)
	sys.exit()
if c[12] >= 2:
	print(0)
	sys.exit()

reserved = []
alternatives = []
for k, v in c.items():
	if v == 2:
		reserved.append(k)
		reserved.append(24-k)
	elif k == 12:
		reserved.append(12)
	else:
		alternatives.append(k)

m = len(alternatives)
#print(m)
ans = 0
for i in range(2**m):
	zones = copy(reserved)
	for j, a in enumerate(alternatives):
		if (i>>j)&1:
			zones.append(24-a)
		else:
			zones.append(a)
	zones.sort()
	zones = [0] + zones + [24]
	#print(zones)
	res = 24
	for j in range(len(zones)-1):
		res = min(res, zones[j+1]-zones[j])
	ans = max(ans, res)

print(ans)