n = gets.to_i
xs = gets.chomp.split.map(&:to_i)

ss = xs.map { |x| [x, 24 - x].min }

n.times do |i|
  n.times do |j|
    next if i >= j
    ss << [(xs[i] - xs[j]).abs, ((24 - xs[i]) - xs[j]).abs].max
  end
end

p ss.min
