def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
d=i2()
e=[[d[0],24-d[0]]]
ccc=100

for i in range(1,n):
 cc=[]
 for j in [d[i],24-d[i]]:
  c=100
  for k in e:
   x=abs(j-k[0])
   x=min(x,24-x)
   y=abs(j-k[1])
   y=min(y,24-x)
   c=min(c,max(x,y))
  cc.append(c)
 ccc=min(ccc,max(cc))
 e.append([d[i],24-d[i]])

if ccc==100:
   print(min(d[0],24-d[0]))
else:
   print(ccc)