import Data.Array.Base (unsafeRead, unsafeWrite) import Data.Int (Int64) import qualified Data.Array.IO as I main :: IO () main = do (n, k) <- fmap ((\[a, b] -> (read a, read b)) . words) $ getLine :: IO (Int, Int64) ds <- fmap (map (flip (-) 1 . read) . words) $ getLine :: IO [Int] is <- I.newListArray (0, n - 1) ds :: IO (I.IOUArray Int Int) result <- sortCount n k 0 is putStrLn result sortCount :: Int -> Int64 -> Int -> I.IOUArray Int Int -> IO (String) sortCount n k i _ | k < 0 = return "NO" | n == i = return $ if odd k then "NO" else "YES" sortCount n k i xs = do a1 <- unsafeRead xs i if a1 == i then sortCount n k (i + 1) xs else do a2 <- unsafeRead xs a1 unsafeWrite xs i a2 unsafeWrite xs a1 a1 sortCount n (k - 1) i xs