n = int(eval(input()))

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



cur = h[-1]

i = n - 2

flg = True

while i >= 0:

    if h[i] <= cur + 1:

        cur = min(cur, h[i])

    else:

        flg = False

        break

    i -= 1



print(('Yes' if flg else 'No'))

def main():

    N = int(eval(input()))

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



    cond = True

    p = H[0] - 1

    for h in H[1:]:

        if p < h:

            p = h - 1

        elif p == h:

            pass

        else:

            cond = False

            break



    print(('Yes' if cond else 'No'))





if __name__ == '__main__':

    main()

n = int(eval(input()))
h = list(map(int, input().split()))
cur = h[-1]
i = n - 2
flg = True
while i >= 0:
    if h[i] <= cur + 1:
        cur = min(cur, h[i])
    else:
        flg = False
        break
    i -= 1
print(("Yes" if flg else "No"))

def main():
    N = int(eval(input()))
    (*H,) = list(map(int, input().split()))
    cond = True
    p = H[0] - 1
    for h in H[1:]:
        if p < h:
            p = h - 1
        elif p == h:
            pass
        else:
            cond = False
            break
    print(("Yes" if cond else "No"))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -h = list(map(int, input().split())) -cur = h[-1] -i = n - 2 -flg = True -while i >= 0: -    if h[i] <= cur + 1: -        cur = min(cur, h[i]) -    else: -        flg = False -        break -    i -= 1 -print(("Yes" if flg else "No")) +def main(): +    N = int(eval(input())) +    (*H,) = list(map(int, input().split())) +    cond = True +    p = H[0] - 1 +    for h in H[1:]: +        if p < h: +            p = h - 1 +        elif p == h: +            pass +        else: +            cond = False +            break +    print(("Yes" if cond else "No")) + + +if __name__ == "__main__": +    main()