a=ARGF.gets_to_end.split.map &.to_i
n=a.shift
r=0
1.times{|x|(1<<n).times{|i|
b=n.times.map{|j|(x+a[j]*((i>>j&1)*2-1))%24}.to_a+[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