Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.reverse()
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range (N-1):
        if A[i] < A[1+i]:
            if (A[1+i] - A[i]) == 1:
                A[i+1] -= 1
            else:
                break
if i != (N-2):
    print("No")
else:
    print("Yes")

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range (N-1):
        if A[-(1 + i)] < A[-(2 + i)]:
            if (A[-(2 + i)] - A[-(1 + i)]) == 1:
                A[-(2 + i)] -= 1
            else:
                k = 114514
if k == 114514:
    print("No")
else:
    print("Yes")        

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range (N-1):
        if A[N-(1 + i)] < A[N-(2 + i)]:
            if (A[N-(2 + i)] - A[N-(1 + i)]) == 1:
                A[N-(2 + i)] -= 1
            else:
                k = 114514
if k == 114514:
    print("No")
else:
    print("Yes")             

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range (N-1):
        if A[N-(1 + i)] < A[N-(2 + i)]:
            if (A[N-(2 + i)] - A[N-(1 + i)]) == 1:
                A[N-(2 + i)] -= 1
            else:
                k = 114514
                break
if k == 114514:
    print("No")
else:
    print("Yes")             

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range (N-1):
        if A[N-1 -i] < A[N-2-i]:
            if (A[N-2-i] - A[N-1-i]) == 1:
                A[N-2-i] -= 1
            else:
                k = 114514
                break
if k == 114514:
    print("No")
else:
    print("Yes")             

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')