N = int(eval(input()))

H = list(map(int,input().split()))



for i in range(N-1, 1, -1):

  if H[i] >= H[i-1]:

    continue

  if H[i] < H[i-1]:

    if H[i - 1] - 1 == H[i]:

      H[i - 1] -= 1

    else:

      print("No")

      exit()

print("Yes")
import sys



stdin = sys.stdin



ns = lambda : stdin.readline().rstrip()

ni = lambda : int(ns())

na = lambda : list(map(int, stdin.readline().split()))



def main():

  n = ni()

  a = na()



  for i in range(n - 1, 1, -1):

    if a[i] > a[i - 1]:

      continue

    if a[i] < a[i - 1]:

      if a[i] == a[i - 1] - 1:

        a[i - 1] -= 1

        continue

    if a[i] == a[i - 1]:

      continue

    print("No")

    return

  print("Yes")

main()
N = int(eval(input()))
H = list(map(int, input().split()))
for i in range(N - 1, 1, -1):
    if H[i] >= H[i - 1]:
        continue
    if H[i] < H[i - 1]:
        if H[i - 1] - 1 == H[i]:
            H[i - 1] -= 1
        else:
            print("No")
            exit()
print("Yes")

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n = ni()
    a = na()
    for i in range(n - 1, 1, -1):
        if a[i] > a[i - 1]:
            continue
        if a[i] < a[i - 1]:
            if a[i] == a[i - 1] - 1:
                a[i - 1] -= 1
                continue
        if a[i] == a[i - 1]:
            continue
        print("No")
        return
    print("Yes")


main()

-N = int(eval(input())) -H = list(map(int, input().split())) -for i in range(N - 1, 1, -1): -    if H[i] >= H[i - 1]: -        continue -    if H[i] < H[i - 1]: -        if H[i - 1] - 1 == H[i]: -            H[i - 1] -= 1 -        else: -            print("No") -            exit() -print("Yes") +import sys + +stdin = sys.stdin +ns = lambda: stdin.readline().rstrip() +ni = lambda: int(ns()) +na = lambda: list(map(int, stdin.readline().split())) + + +def main(): +    n = ni() +    a = na() +    for i in range(n - 1, 1, -1): +        if a[i] > a[i - 1]: +            continue +        if a[i] < a[i - 1]: +            if a[i] == a[i - 1] - 1: +                a[i - 1] -= 1 +                continue +        if a[i] == a[i - 1]: +            continue +        print("No") +        return +    print("Yes") + + +main()