import sys
N=int(input())
D=[int(i) for i in input().split()]
L=[0]*13
L[0]=1
for d in D:
    L[d]+=1
for s in L:
    if s>=3:
        print(0)
        sys.exit()
if L[0]>=2 or L[12]>=2:
    print(0)
    sys.exit()
#print(L)
def check(K):
    sta=0
    #end=0
    num=10**9
    ans=10**9
    while sta<24:
        if K[sta]==1:
            ans=min(ans,num)
            num=0
        sta+=1
        num+=1
        #print(num,sta,ans)
    ans=min(num,ans)
    return ans


ans=-1
for s in range(1<<11):
    K=[0]*24
    K[0]=1
    if L[12]==1:
        K[12]=1
    for j in range(11):
        if L[j+1]==0:
            continue
        if L[j+1]==2:
            K[j+1]=1
            K[24-(j+1)]=1
            continue
        if (s&(1<<j)):
            K[j+1]=1
        else:
            K[24-(j+1)]=1
    ans=max(ans,check(K))
print(ans)