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

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1

if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        #print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

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

i = 0
flag = 0
for i in range(1,n-1):
    #print(h)
    if(h[i] > h[i+1] + 1):
        break
        flag = 1
    elif(h[i] == h[i+1]+1):
        if(h[i-1] == h[i]):
            break
            flag = 1
        else:
            h[i] -= 1
    elif(h[i-1] != h[i]):
        h[i] -= 1

if(h[-2] > h[-1]):
    flag = 1    


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        #print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

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

i = 0
flag = 0
for i in range(1,n-1):
    print(h)
    if(h[i] > h[i+1]+2):
        break
        flag = 1
    elif(h[i] >= h[i+1]+1):
        if(h[i-1] == h[i]):
            break
            flag = 1
        else:
            h[i] -= 1
    elif(h[i-1] != h[i]):
        h[i] -= 1

if(h[n-2] > h[n-1]):
    flag = 1    



if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        #print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")