def timdiff(dif):
    l=[]
    for i in range(24):
        if dif[i]==1:
            l+=[i]
        if dif[i]>=2:
            return 0
    m=24
    for i in range(len(l)):
        if i < len(l)-1:
            m=min(m,l[i+1]-l[i])
    if len(l)>=2:
        m=min(m,24-l[len(l)-1])
    return m

n=int(input())
d=list(map(int,input().split(' ')))
diff=[0]*24
if n>=24:
    print(0)
elif n<12: #global search
    m=0
    for i in range(2**n):
        for j in range(1,24):
            diff[j]=0
        diff[0]=1
        for j in range(n):
            if (i >> j)%2==1:
                diff[d[j]]+=1
            elif d[j]==0:
                diff[0]+=1
            else:
                diff[24-d[j]]+=1
        m=max(m,timdiff(diff))
    print(m)
else: #judge 0 or 1
    bl=False
    for i in range(13):
        if bl:
            break
        m=0
        for j in range(n):
            if d[j] == i:
                m+=1
            if m>2 or (i==0 and d[j]==0) or (i==12 and m>=2):
                break
        bl=True
    if bl:
        print(1)
    else:
        print(0)
