import Data.List

f::Int->Int->Char
f n k
   |n<=k='w'
   |otherwise=' '

f2::Int->[Int]->Int
f2 n xs =let ys=filter ((==' ').head) $ group $ map (f n) xs
         in (length ys)

main=do
     e<-getLine
     es<-getLine
     let xs=map read (words es)::[Int]
         ys=map ((-) (maximum xs)) xs
     putStrLn $ show $ sum [f2 e ys|e<-[0..100]]