-- 135B 0 or 1 swap

main :: IO()
main = do
  n_str <- getLine
  let n = read n_str :: Int
  s_str <- getLine
  let source = take n (map read (words s_str) :: [Int])
  let hint = solve source 0
  if hint == 0
    then
    putStrLn("YES")
    else
    putStrLn("NO")

solve :: [Int] -> Int -> Int
solve (x:xs:xs2) c =
  if x > xs
  then
    solve (xs:xs2) (abs(c) - abs(x - xs))
  else
    solve (xs:xs2) c
solve x c = c
