n = int(input()) people = list(map(int,input().split())) sorts = people[:] sorts.sort() if people == sorts: print("YES") else: print("NO")