main :: IO ()
main = do
  n <- read <$> getLine :: IO Integer
  ps <- map read.lines <$> getContents :: IO [Integer]
  let m = n`div`2
      as = filter (<=m) ps
      bs = filter (>m) ps
      aa = fromIntegral $ length $ takeWhile (==0) $ zipWith (-) [m,m-1..] $ reverse as
      ba = fromIntegral $ length $ takeWhile (==0) $ zipWith (-) [m+1,m+2..] bs
      ans1 = max 0 (m-aa-1)+max 0 (m-ba-1)
  print $ if ans1 == 0
            then if as == take (fromIntegral m) ps
              then 0
              else m
            else ans1
