import sys

input = sys.stdin.readline



import numpy as np



# Aへの加算は、imos法でまとめて行える。

# +[1,2,3,4,5]

# 階差：[-4,1,1,1,1]

# 総回数と最終的な階差から、回数分布がわかる



N = int(eval(input()))

A = np.array(input().split(), dtype=np.int64)



total_op = A.sum() // (N*(N+1)//2)



diff = np.empty_like(A)

diff[1:] = np.diff(A)

diff[0] = A[0] - A[-1]



# 操作の起点となる回数

op = (total_op - diff)//N



bl = True

bl &= (total_op * (N*(N+1)//2) == A.sum())

bl &= (N*op + diff == total_op).all()

bl &= (op >= 0).all()



answer = 'YES' if bl else 'NO'

print(answer)
import sys

import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N = int(readline())

A = np.array(read().split(), np.int64)



def main(N, A):

    k = N * (N + 1) // 2

    t = A.sum() // k

    if k * t != A.sum():

        return False

    B = np.empty_like(A)

    B[1:] = A[1:] - A[:-1]

    B[0] = A[0] - A[-1]

    B -= t

    if np.any(B % N != 0):

        return False

    B //= (-N)

    return np.all(B >= 0)



print(('YES' if main(N, A) else 'NO'))
import sys

input = sys.stdin.readline
import numpy as np

# Aへの加算は、imos法でまとめて行える。
# +[1,2,3,4,5]
# 階差：[-4,1,1,1,1]
# 総回数と最終的な階差から、回数分布がわかる
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
total_op = A.sum() // (N * (N + 1) // 2)
diff = np.empty_like(A)
diff[1:] = np.diff(A)
diff[0] = A[0] - A[-1]
# 操作の起点となる回数
op = (total_op - diff) // N
bl = True
bl &= total_op * (N * (N + 1) // 2) == A.sum()
bl &= (N * op + diff == total_op).all()
bl &= (op >= 0).all()
answer = "YES" if bl else "NO"
print(answer)

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = np.array(read().split(), np.int64)


def main(N, A):
    k = N * (N + 1) // 2
    t = A.sum() // k
    if k * t != A.sum():
        return False
    B = np.empty_like(A)
    B[1:] = A[1:] - A[:-1]
    B[0] = A[0] - A[-1]
    B -= t
    if np.any(B % N != 0):
        return False
    B //= -N
    return np.all(B >= 0)


print(("YES" if main(N, A) else "NO"))

- -input = sys.stdin.readline -# Aへの加算は、imos法でまとめて行える。 -# +[1,2,3,4,5] -# 階差：[-4,1,1,1,1] -# 総回数と最終的な階差から、回数分布がわかる -N = int(eval(input())) -A = np.array(input().split(), dtype=np.int64) -total_op = A.sum() // (N * (N + 1) // 2) -diff = np.empty_like(A) -diff[1:] = np.diff(A) -diff[0] = A[0] - A[-1] -# 操作の起点となる回数 -op = (total_op - diff) // N -bl = True -bl &= total_op * (N * (N + 1) // 2) == A.sum() -bl &= (N * op + diff == total_op).all() -bl &= (op >= 0).all() -answer = "YES" if bl else "NO" -print(answer) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N = int(readline()) +A = np.array(read().split(), np.int64) + + +def main(N, A): +    k = N * (N + 1) // 2 +    t = A.sum() // k +    if k * t != A.sum(): +        return False +    B = np.empty_like(A) +    B[1:] = A[1:] - A[:-1] +    B[0] = A[0] - A[-1] +    B -= t +    if np.any(B % N != 0): +        return False +    B //= -N +    return np.all(B >= 0) + + +print(("YES" if main(N, A) else "NO"))