n,*a=`dd`.split.map &:to_i
r=0
24.times{|x|(1<<n).times{|i|
b=n.times.map{|j|(x+a[j]*(i[j]*2-1))%24}+[x]
s=24
(n+1).times{|j|(j+1..n).each{|k|s=[s,(b[j]-b[k])%24,(b[k]-b[j])%24].min}}
r=[r,s].max
}}
p r