import operator N, lis = int(input()), [int(i) for i in input().split()] sa = set(map(operator.sub, lis, lis[1:])) if len(lis) == N and len(sa) == 1: print("YES") else: print("NO")