Buggy python submission (verdict: Runtime Error):
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[i]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)
                
    if flag:
        print('Yes')
    else:
        print('No')

Fixed submission:
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[0]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

    if flag:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[i]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[0]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

    if flag:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
height_lst = list(map(int,input().split()))

flag = True
point = 0
count = 0

if n==1:
    print('Yes')
else:
    for i in range(n-1):
        height1 = height_lst[i]
        height2 = height_lst[i+1]
        poor = height2-height1

        if poor<=-2:
            flag = False
            break
        elif poor==-1:
            point += 1
            if point==2:
                flag = False
                break
        else:
            continue

if flag:
    height1 = height_lst[-2]
    height2 = height_lst[-1]
    poor = height2-height1

    if poor<=-2:
        print('No')
    elif poor==-1:
        if point==0:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

else:
    print('No')

Fixed submission:
n = int(input())
height_lst = list(map(int,input().split()))
flag = True

if n==1:
    print('Yes')
else:
    if height_lst[0]==1:
        height1 = 1
    elif height_lst[0]>1:
        height1 = height_lst[0]-1

    for i in range(1,n):
        height = height_lst[i]
        if height==1:
            possible_lst = [1]
        elif height>1:
            possible_lst = [height-1,height]

        if max(possible_lst)<height1:
            flag = False
            break
        else:
            if min(possible_lst)>=height1:
                height1 = min(possible_lst)
            else:
                height1 = max(possible_lst)

    if flag:
        print('Yes')
    else:
        print('No')