while True:
x = int(input())
if x >=1 and x <=10**5:
break
list = []
list=(input())
list= list.split(" ")
flag = True
for i in range(len(list)-1):
if int(list [i]) > int(list[i+1]):
flag = False
break
if flag:
print("YES")
else:
print("NO")