
N=int(input())

D=list(map(int,input().split()))
flg =False
A = [0 for i in range(13)]
A[0]=1
for i in range(N):
    j = min(i,24-i)
    if j==0:
        flg=True
        break
    elif j==12:
        if A[j]==1:
            flg=True
            break
        else:
            A[j]+=1
    else:
        if A[j]==2:
            flg=True
            break
        else:
            A[j]+=1

import copy

if flg:
    print(0)
else:
    count=0
    one_times=[]
    times=[0]
    for i in range(1,12): 
        if A[i]==1:
            count+=1
            one_times.append(i)
        if A[i]==2:
            times.append(i)
            times.append(24-i)
    if A[12]==1:
        times.append(12)
    score_max=0
    for i in range(2**count):
        t=copy.copy(times)
        for j in range(count):
            if (i//(2**j))%2==0:
                t.append(one_times[j])
            else:
                t.append(24-one_times[j])
        t.sort()
        score_min=24
        for j in range(len(t)):
            if j==len(t)-1:
                score_min=min(t[0]+24-t[len(t)-1],score_min)
            else:
                score_min=min(t[j+1]-t[j],score_min)
        score_max=(score_min,score_max)
    print(score_max)