N = int(input()) X = [int(a) for a in input().split()] D = set([r-l for l,r in zip(X[:-1],X[1:])]) print("YES" if len(D) == 1 else "NO")