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