genl :: Int -> [Int] -> [(Int,Int)]
genl _ [] = []
genl n (x:xs) = (n,x):(genl (n+1) xs)

bsort :: [(Int,Int)] -> [(Int,Int)]
bsort [] = []
bsort [x] = [x]
bsort (x:y:l) = if (snd x) > (snd y) then y:(bsort (x:l)) else x:(bsort (y:l))

bsorts :: Int -> [(Int,Int)] -> [(Int,Int)]
bsorts 0 l = l
bsorts n l = bsorts (n-1) (bsort l)

main :: IO ()
main = do
   n <- read <$> getLine
   l' <- map read.words <$> getLine
   let ave = sum l'
       l = bsorts n $ genl 0 (map (\x -> (abs $ x*n - ave)) l')
   putStrLn $ show $ fst $ head l