import copy

N=int(input())
D=list(map(int,input().split()))
D.sort()
time=[]
kakutei=[]
tmp=0
for d in D: 
  if d==0:
    print(0)
    exit()
  elif tmp==d:
    count+=1
    if count>=2 or (d==12 and count>=1):
      print(0)
      exit()
  else:
    count=0
  if d not in time:
    if d==12:
      kakutei.append(d)
    else:
      time.append(d)
  elif 24-d not in time and d!=12:
    kakutei.append(d)
    kakutei.append(24-d)
    time.remove(d)
  tmp=d
kakutei.append(0)
ans=0
if len(time)==0:
  kakutei.sort()
  minclock=12
  for j in range(len(kakutei)-1):
    minclock=min(minclock,kakutei[j+1]-kakutei[j])
  ans=max(ans,minclock)
  print(ans)
  exit()
for i in range(2**len(time)):
  clock=kakutei.copy()
  bit = format(i, "b").zfill(len(time))
  for i in range(len(bit)):
    if bit[i]=='0':
      clock.append(time[i])
    else:
      clock.append(24-time[i])
  clock.sort()
  minclock=12
  for j in range(len(clock)-1):
    minclock=min(minclock,clock[j+1]-clock[j])
  ans=max(ans,minclock)
print(ans)