N=int(input())
from collections import defaultdict
data=defaultdict(int)
data[0]+=1
for d in map(int,input().split()):
    data[d]+=1
check=[[]]
ans=1
for d in data.keys():
    if data[d]>2:
        ans=0
        break
    checkc=check.copy()
    if data[d]==2:
        if d==0 or d==12:
            ans=0
            break
        for c in check:
            c+=[d,-1*d]
    elif data[d]==1:
        if d==0:
            for c in check:
                c.append(d)
            continue
        check=[]
        for c in checkc:
            check.append(c+[d])
            check.append(c+[-1*d])
if ans!=0:
    ans=0
    for c in check:
        c.sort()
        now=24
        for i in range(len(c)):
            now=min(now,(c[i]-c[i-1])%24)
        ans=max(now,ans)
print(ans)