n=gets.to_i
d=gets.split.map(&:to_i).sort
x=Array.new(24,0)
x[0]=1
d.each.with_index{|t, i|
  if i%2==0 then
    x[t]=1
  else
    x[-t]=1
  end
}

y=[]
x.size.times{|i|
  y << i if x[i]==1
}

z=[]
(y.size-1).times{|i|
  z << y[i+1]-y[i]
}
z << (24-y[-1]+y[0])%24

p z.min