Buggy python submission (verdict: Runtime Error):
# coding:utf-8
# C - Grand Garden

N = int(input())
h = list(map(int,input().split()))
h += [0]
ans = 0

for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False

print(ans)


Fixed submission:
N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8
# C - Grand Garden

N = int(input())
h = list(map(int,input().split()))
h += [0]
ans = 0

for _ in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False

print(ans)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8
# C - Grand Garden

N = int(input())
h = list(map(int,input().split()))
h += [0]
ans = 0

for _ in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                mini_ans += 1
            add = False

print(ans)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8
# C - Grand Garden

N = int(input())
h = list(map(int,input().split()))
h += [0]
ans = 0

for _ in range(1000):
    mini_ans = 0
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                mini_ans += 1
            add = False
    
    if mini_ans == 0:
        break
    else:
        ans += mini_ans

print(ans)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8
# C - Grand Garden

N = int(input())
h =  [int(i) for i in input().split()]
h += [0]
ans = 0

for _ in range(1000000):
    mini_ans = 0
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                mini_ans += 1
            add = False
    
    if mini_ans == 0:
        break
    else:
        ans += mini_ans

print(ans)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)

Buggy python submission (verdict: Runtime Error):
# coding:utf-8
# C - Grand Garden

N = int(input())
h =  [int(i) for i in input().split()]
h += [0]
ans = 0

while True:
    mini_ans = 0
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                mini_ans += 1
            add = False
    if mini_ans == 0:
        break
    else:
        ans += mini_ans

print(ans)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)