def main():

    n = int(eval(input()))

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



    h = list(reversed(h))

    flag = True



    for i in range(1,len(h)):

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

            flag = False

        elif h[i] - h[i-1] == 1:

            h[i] -= 1

        

    if flag:

        print('Yes')

    else:

        print('No')



main()


from sys import exit



ii = lambda : int(eval(input()))

mi = lambda : list(map(int,input().split()))

li = lambda : list(map(int,input().split()))





def main():

    n = ii()

    a = li()



    a = reversed(a)



    m = 100000000000

    for i in a:

        m = min(m,i)

        if i > m+1:

            print("No")

            exit()



    print("Yes")







    

main()

def main():
    n = int(eval(input()))
    h = list(map(int, input().split()))
    h = list(reversed(h))
    flag = True
    for i in range(1, len(h)):
        if h[i] - h[i - 1] > 1:
            flag = False
        elif h[i] - h[i - 1] == 1:
            h[i] -= 1
    if flag:
        print("Yes")
    else:
        print("No")


main()

from sys import exit

ii = lambda: int(eval(input()))
mi = lambda: list(map(int, input().split()))
li = lambda: list(map(int, input().split()))


def main():
    n = ii()
    a = li()
    a = reversed(a)
    m = 100000000000
    for i in a:
        m = min(m, i)
        if i > m + 1:
            print("No")
            exit()
    print("Yes")


main()

+from sys import exit + +ii = lambda: int(eval(input())) +mi = lambda: list(map(int, input().split())) +li = lambda: list(map(int, input().split())) + + -    n = int(eval(input())) -    h = list(map(int, input().split())) -    h = list(reversed(h)) -    flag = True -    for i in range(1, len(h)): -        if h[i] - h[i - 1] > 1: -            flag = False -        elif h[i] - h[i - 1] == 1: -            h[i] -= 1 -    if flag: -        print("Yes") -    else: -        print("No") +    n = ii() +    a = li() +    a = reversed(a) +    m = 100000000000 +    for i in a: +        m = min(m, i) +        if i > m + 1: +            print("No") +            exit() +    print("Yes")