n = int(input()) people = list(map(int,input().split())) if people == sorted(people): print("YES") else: print("NO")