n = int(input()) a = list(map(int, input().split())) if n == 1: print("Yes") else: # Check if all elements are the same and greater than 1 all_same = True first = a[0] for num in a[1:]: if num != first: all_same = False break if all_same and first > 1: print("No") else: # Check if for any i, a[i] > a[i+1] + 1 impossible = False for i in range(n-1): if a[i] > a[i+1] + 1: impossible = True break if impossible: print("No") else: print("Yes")