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

flag = True

for i in range(N):
    if H[i]-1 > min(H[i:N]):
        flag = False
        break

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

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(N-2):
    if H[i] - 1 > H[i+1] or H[i] - 1 > H[i+2]:
        ans = "No"
        break
if H[-2] - 1 > H[-1] and ans == "Yes":
    ans = "No"


print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(1, N-1):
    if max(H[0: i]) - 1 > min(H[i: N]):
        ans = "No"
        break
print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(1, N-1):

    if H[i] > H[i+1] and max(H[0: i]) - 1 > min(H[i: N]):
        ans = "No"
        break
print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(1, N-1):

    if H[i] > H[i+1] and max(H[0: i]) - 1 > min(H[i: N]):
        ans = "No"
        break
print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(1, N-1):

    if H[i] > H[i+1] and max(H[0: i]) - 1 > min(H[i: N]) and ans == "Yes":
        ans = "No"

print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(1, N-1):
    if max(H[0: i]) - 1 > min(H[i: N]) and ans == "Yes":
        ans = "No"

print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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

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

ans = "Yes"

for i in range(1, N-1):
    if max(H[0: i]) - 1 > min(H[i: N]) and ans == "Yes":
        ans = "No"

print(ans)

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

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