import Control.Monad
import Data.Array
import Data.List (sort)

main :: IO ()
main = do
  n <- readLn
  a <- replicateM n readLn
  let
    po = array (0, 100000) $ zip a [1..]
    meu = array (0, 100000) $ zip (sort a) [1..]
    solve [] = 0
    solve (x:xs) = if (po ! x + meu ! x) `mod` 2 == 0
      then solve xs
      else 1 + solve xs
  print $ solve a `div` 2
