import qualified Data.ByteString.Char8 as B
import Data.List
main=do
    n<-readLn::IO Int
    as<-map read.words<$>getLine::IO[Int]
    print $ sol n as

sol n as = snd $ minimum $ zip (map (\a->abs(a*n-sm)) as) [0..]
    where
        sm = sum as
