n=input()
a=map(int,raw_input().split())
r=0
for i in range(1<<n):
 b=[a[j]*((i>>j&1)*2-1)%24 for j in range(n)]+[0]
 s=24
 for j in range(n):
  for k in range(j+1,n+1):s=min(s,(b[j]-b[k])%24,(b[k]-b[j])%24)
 r=max(r,s)
print r