import Control.Applicative (ZipList (..))
import Control.Monad (guard)

main = getLine >>= putStrLn . show . solve . map read . words

solve ns
    | all even ns || all odd ns = solve' 0 ns
    | otherwise                 = solve' 1 $ alignParity ns
  where
    alignParity ns = head $ do
        op <- [ [(+1), (+1), (+0)]
              , [(+1), (+0), (+1)]
              , [(+0), (+1), (+1)]
              ]
        let ns' = getZipList $ ZipList op <*> ZipList ns
        guard $ all even ns' || all odd ns'
        return ns'

solve' n xs =
    let largest = maximum xs
        xs' = map (abs . subtract largest) xs
    in (sum xs') `div` 2 + n
