import Control.Applicative ((<$>))
import Data.List (sort)

partitionNumber :: Int -> [[Int]]
partitionNumber n = part_int n n [] []
  where
    part_int 0 _ xs ys = reverse xs:ys
    part_int 1 _ xs ys = reverse (1:xs):ys
    part_int n 1 xs ys = reverse (replicate n 1 ++ xs):ys
    part_int n k xs ys =
      let ys' = part_int n (k - 1) xs ys
      in if n - k >= 0 then part_int (n - k) k (k:xs) ys' else ys'

partitions :: Int -> Int -> [[Int]]
partitions x d = filter (\l->length l==d) $ partitionNumber x

rotate n x
  | x == n = 1
  | otherwise = x+1

check :: [Int] -> Int -> [Int] -> Bool
check [] _ _ = True
check (a:as) n xs
  | sum xs == a = check as n $ map (rotate n) xs
  | otherwise = False

solve :: [Int] -> [(Int,Int)] -> Int -> Int -> Bool
solve as ais n d = do
  let ma = minimum as
      starts = map snd $ takeWhile ((==ma).fst) ais
      ss = [(s,xs)|s<-starts,xs<-partitions ma d]
  any (\(s,xs)-> check (drop s as ++ take s as) n xs) ss

main = do
  n <- read <$> getLine :: IO Int
  as <- map read.words <$> getLine :: IO [Int]
  let m = n*(n+1)`div`2
      s = sum as
      ais = sort $ zip as [0..]
  case s `divMod` m of
    (d,0) -> putStrLn $ if solve as ais n d then "YES" else "NO"
    _ -> putStrLn "NO"
