n = int(input()) tmp = input() k = tmp.split(" ") cond = True for i in range(0, n - 1): if (int(k[i]) > int(k[i+1]) and cond): print("NO") cond = False if (cond): print("YES")