from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())


N = int(input())
dd = inpl()

cnt = [0]*13
for d in dd:
    cnt[d] += 1

koho = [0]
ed1 = []

if cnt[0] > 0:
    print(0)
    sys.exit()

if cnt[12] >= 2:
    print(0)
    sys.exit()
elif cnt[12] == 1:
    koho.append(12)


for d,n in enumerate(cnt):
    if d == 12:
        continue
    if n >= 3:
        print(0)
        sys.exit()
    elif n == 2:
        koho.append(d)
        koho.append(24-d)
    elif n == 1:
        ed1.append(d)

L = len(ed1)
ans = 0
if L != 0:
    for bit in range((1<<L)-1):
        tmp = koho[:]
        for b in range(L):
            if bit & (1<<b):
                tmp.append(ed1[b])
            else:
                tmp.append(24-ed1[b])

        tmp.sort()
        azusa = INF
        azunyan = len(tmp)
        for x in range(1,azunyan):
            azusa = min(tmp[x]-tmp[x-1],azusa)
        ans = max(azusa,ans)
else:
    tmp = koho[:]
    azunyan = len(tmp)
    ans = INF
    for x in range(1,azunyan):
        ans = min(tmp[x]-tmp[x-1],ans)

print(ans)
