import sys

 

n = int(eval(input()))

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

maxnum = 0



for x in range(n):

    if maxnum < nums[x]:

        maxnum = nums[x]

    if maxnum - nums[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

n = int(eval(input()))
nums = list(map(int, input().split()))
maxnum = 0
for x in range(n):
    if maxnum < nums[x]:
        maxnum = nums[x]
    if maxnum - nums[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()

-n = int(eval(input())) -nums = list(map(int, input().split())) -maxnum = 0 -for x in range(n): -    if maxnum < nums[x]: -        maxnum = nums[x] -    if maxnum - nums[x] > 1: -        print("No") -        sys.exit() -print("Yes") +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()