def solve(arr,x): for i in (0,x-2): if(arr[i+1]<arr[i]): return "NO" break return "YES" T = int(input()) arr = [int(x) for x in input().split()] print(solve(arr,T))