import Data.Set
main = do
    n_ <- readLn::IO Int
    as_ <- return . Prelude.map read . words =<< getLine
    let
	ahead:talea = as_
	diffSum v [a] = v + ahead - a
	diffSum v (a:tl@(aa:as)) = diffSum (v+aa-a) tl
	st = fromList as_
    putStr $ if 0 == diffSum 0 as_ && size st == n_
	then "YES"
	else "NO"