# Original solution
import collections
from collections import deque
N=int(eval(input()))
D=list(map(int,input().split()))
c=collections.Counter(D)
count0=0
count12=0
zeroflag=0
l=[]
if c[12]>0:
    count12=c[12]
if c[0]>0:
    count0=c[0]+1
#print(l,count0,count12)
#print(n)
allmax=0
q=deque()
l=[]



if (count0==0)and(zeroflag==0):
    q.append([0])
    q.append([24])
elif (count0==1)and(zeroflag==0):
    q.append([0,0])
    q.append([0,24])
    q.append([24,24])
else:
    zeroflag=1

if (count12==1)and(zeroflag==0):
    length=len(q)
    j=0
    while j<length:
        buf1=[]
        l=q.popleft()
        buf1.extend(l)
        l.append(12)
        q.append(l)
        j=j+1
elif count12>1:
    zeroflag=1

if zeroflag==0:
    for i in range(1,12):
        length=len(q)
        j=0
        if c[i]==0: continue
        if c[i]==1:
            while j<length:
                buf1=[]
                buf2=[]
                l=q.popleft()
                buf1.extend(l)
                buf1.append(i)
                buf2.extend(l)
                buf2.append(24-i)
                q.append(buf1)
                q.append(buf2)
                j=j+1
        if c[i]==2:
            while j<length:
                buf1=[]
                buf2=[]
                buf3=[]
                l=q.popleft()
                buf1.extend(l)
                buf1.extend([i,i])
                buf2.extend(l)
                buf2.extend([24-i,24-i])
                buf3.extend(l)
                buf3.extend([i,24-i])
                q.append(buf1)
                q.append(buf2)
                q.append(buf3)
                j=j+1
        if c[i]>2:
            zeroflag=1
            break
        #print(q)

#print(q)

if zeroflag==0:
    for l in q:
        l.sort()
        mi=100
        n=len(l)
        for j in range(n-1):
            mi=min(mi,l[j+1]-l[j],24-l[j+1]+l[j])
        mi=min(mi,l[n-1],24-l[n-1])
    #print(mi)
        allmax=max(allmax,mi)
else:
    allmax=0
print(allmax)

"""
for i in range(pow(2,n)):
    buf=[0]
    bit=[0]*n
    mi=100
    if count12==1:
        buf.append(12)
    buf.append(0)
    for j in range(n):
        if (i>>j)&1:
            bit[j]=1
    #print(bit)
    for j in range(n):
        buf.append(l[j][bit[j]])
    buf.sort()
    buf.append(24)
    #print(buf)
    for j in range(len(buf)-1):
        mi=min(mi,buf[j+1]-buf[j])
    allmax=max(allmax,mi)
print(allmax)
"""


# Optimized solution
import collections
from collections import deque
N=int(eval(input()))
D=list(map(int,input().split()))
c=collections.Counter(D)
count0=0
count12=0
zeroflag=0
l=[]
if c[12]>0:
    count12=c[12]
if c[0]>0:
    count0=c[0]+1
#print(l,count0,count12)
#print(n)
allmax=0
q=deque()
l=[]



if (count0==0)and(zeroflag==0):
    q.append([0])
else:
    zeroflag=1

if (count12==1)and(zeroflag==0):
    length=len(q)
    j=0
    while j<length:
        buf1=[]
        l=q.popleft()
        buf1.extend(l)
        l.append(12)
        q.append(l)
        j=j+1
elif count12>1:
    zeroflag=1

if zeroflag==0:
    for i in range(1,12):
        length=len(q)
        j=0
        if c[i]==0: continue
        if c[i]==1:
            while j<length:
                buf1=[]
                buf2=[]
                l=q.popleft()
                buf1.extend(l)
                buf1.append(i)
                buf2.extend(l)
                buf2.append(24-i)
                q.append(buf1)
                q.append(buf2)
                j=j+1
        if c[i]==2:
            while j<length:
                buf1=[]
                buf2=[]
                buf3=[]
                l=q.popleft()
                #buf1.extend(l)
                #buf1.extend([i,i])
                #buf2.extend(l)
                #buf2.extend([24-i,24-i])
                buf3.extend(l)
                buf3.extend([i,24-i])
                #q.append(buf1)
                #q.append(buf2)
                q.append(buf3)
                j=j+1
        if c[i]>2:
            zeroflag=1
            break
        #print(q)

#print(q)

if zeroflag==0:
    for l in q:
        l.sort()
        mi=100
        n=len(l)
        for j in range(n-1):
            mi=min(mi,l[j+1]-l[j],24-l[j+1]+l[j])
        mi=min(mi,l[n-1],24-l[n-1])
    #print(mi)
        allmax=max(allmax,mi)
else:
    allmax=0
print(allmax)