import Data.List

main = do
  _ <- getLine
  ds <- map read . words <$> getLine :: IO [Int]
  let ts = sort $ [0] ++ (concatMap (\g@(h:_) ->if length g > 1 then [h,24-h] else if even h then [h] else [24-h]) ((group . sort) ds)) ++ [24]
  let ans = minimum (zipWith (-) (tail ts) ts)
  print ans