import sys

sys.setrecursionlimit(20000000)

input = sys.stdin.readline



def main():

    n = int(eval(input()))

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



    for x in reversed(list(range(1, len(nums)))):

        if nums[x-1] > nums[x]:

            nums[x-1] -= 1



        if nums[x-1] > nums[x]:

            print('No')

            sys.exit()



    print('Yes')





if __name__ == '__main__':

    main()
import sys



input = sys.stdin.readline

n = int(eval(input()))

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

maxnum = 0



for x in nums:

    if maxnum < x:

        maxnum = x

    if maxnum - x > 1:

        print('No')

        sys.exit() 



print('Yes')

import sys

sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(eval(input()))
    nums = list(map(int, input().split()))
    for x in reversed(list(range(1, len(nums)))):
        if nums[x - 1] > nums[x]:
            nums[x - 1] -= 1
        if nums[x - 1] > nums[x]:
            print("No")
            sys.exit()
    print("Yes")


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
n = int(eval(input()))
nums = list(map(int, input().split()))
maxnum = 0
for x in nums:
    if maxnum < x:
        maxnum = x
    if maxnum - x > 1:
        print("No")
        sys.exit()
print("Yes")

-sys.setrecursionlimit(20000000) - - -def main(): -    n = int(eval(input())) -    nums = list(map(int, input().split())) -    for x in reversed(list(range(1, len(nums)))): -        if nums[x - 1] > nums[x]: -            nums[x - 1] -= 1 -        if nums[x - 1] > nums[x]: -            print("No") -            sys.exit() -    print("Yes") - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +nums = list(map(int, input().split())) +maxnum = 0 +for x in nums: +    if maxnum < x: +        maxnum = x +    if maxnum - x > 1: +        print("No") +        sys.exit() +print("Yes")