Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let sum = Array.fold_left (+) 0 a in
    let g = n * (n + 1) / 2 in
    print_endline @@
        if sum mod g <> 0 then "NO" else (
            let k = sum / g in
            let d = Array.init n (fun i -> a.((i + 1) mod n) - a.(i) - k) in
            let rec loop i =
                if i = n then "YES" else
                    if d.(i) <= 0 && d.(i) mod n = 0 then loop (i + 1) else "NO"
            in
            loop 0
        )
)