# t = int(input()) # n = int(input()) # a = list(map(int,input().split())) # a,b,c = map(int,input().split()) #By Tahir Huzaifa n = int(input()) a = list(map(int,input().split())) st = 0 end = n-1 s = a[st] + a[end] # print(s) st+=1 end-=1 f = True while st<=end: if s!= (a[st]+a[end]): # print(s) f=False break st+=1 end-=1 if f: print("YES") else: print("NO")