Buggy python submission (verdict: Runtime Error):
N=int(input())
h=list(map(int, input().split()))
h2=[]

for i in range(N-1):
  if h[i]-h[i+1]>0:
    h2.append(h[i])

output='Yes'

if h[0]-h[1]>1:
  output='No'
  
for i in range(1, N-1):
  if h[i]-h[i-1]>0 and h[i]-h[i+1]>0:
    if h[i]-min(h[i+1:])>1:
      output='No'
      
print(output)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
h=list(map(int, input().split()))

output='Yes'
for i in range(N-1):
  if h[i]-h[i+1]>0:
    if h[i]-min(h[i+1:])>1:
      output='No'
      
print(output)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

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

a=max([h[i]-min(h[i+1:]) for i in range(n-1)])

if a>1:
  print('No')
else:
  print('Yes')

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
h=list(map(int, input().split()))

output='Yes'
for i in range(n-1):
  if h[i]-h[i+1]>0:
    if h[i]-min(h[i:])>1:
      output='No'
      
print(output)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

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

Hsub=[H[i+1]-H[i] for i in range(N-1)]

output='Yes'
for i in range(N):
  if Hsub>0:
    if H[i]-min(H[i+1])>1:
      output='No'
      
print(output)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))

output='Yes'
for i in range(N-1):
  if H[i]-np.min(H[i+1:])>1:
    output='No'
    
print(output)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
H=list(map(int, input().split()))

output='Yes'
for i in range(N-1):
  if H[i]-min(H[i+1:])>1:
    output='No'
    
print(output)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)