Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
 
for i in range(N-1,0,-1) :
    if A[i-1]>A[i] :
        if A[i]<A[i+1] :
            continue
        A.pop(i)
 
if len(A)==1 :
    print(1000)
    exit()

n=len(A)
money=1000
kabu=0
 
 
for i in range(n-1) : 
    if i==n-2 :
        if A[i-1]<=A[i] :
            continue
        elif A[i-1]>A[i] :
            kabu+=money//A[i]
            money-=A[i]*(money//A[i])
 
    if A[i]<A[i+1] and money>=A[i] : #株を買う
        kabu+=money//A[i]
        money-=A[i]*(money//A[i])
 
    elif A[i]>A[i+1] and kabu>0 :    #株を売る
        if A[i+1]>=A[i+2] :          #下がり続けていれば何もしない
            continue
        elif A[i+1]<A[i+2] :
            money+=kabu*A[i]
            kabu=0
 
else :
    money+=kabu*A[n-1]
    print(money)
    

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

money=1000
stock=0

for i in range(N-1) :
    if A[i]<A[i+1] :
        stock=money//A[i]
        money-=stock*A[i]
        money+=stock*A[i+1]

    else :
        continue

print(money)

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

for i in range(N-1,0,-1) :
    if A[i-1]>A[i] :
        if A[i]<A[i+1] :
            continue
        A.pop(i)
print(A)

if len(A)==1 :
    print(1000)
    exit()

n=len(A)
money=1000
kabu=0


for i in range(n-1) : 
    if i==n-2 :
        if A[i-1]<=A[i] :
            continue
        elif A[i-1]>A[i] :
            kabu+=money//A[i]
            money-=A[i]*(money//A[i])

    if A[i]<A[i+1] and money>=A[i] : #株を買う
        kabu+=money//A[i]
        money-=A[i]*(money//A[i])

    elif A[i]>A[i+1] and kabu>0 :    #株を売る
        money+=kabu*A[i]
        kabu=0

else :
    money+=kabu*A[n-1]
    print(money)

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

money=1000
stock=0

for i in range(N-1) :
    if A[i]<A[i+1] :
        stock=money//A[i]
        money-=stock*A[i]
        money+=stock*A[i+1]

    else :
        continue

print(money)

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

for i in range(N-1,0,-1) :
    if A[i-1]>A[i] :
        if A[i]<A[i+1] :
            continue
        A.pop(i)

if len(A)==1 :
    print(1000)
    exit()

n=len(A)
money=1000
kabu=0


for i in range(n-1) : 
    if i==n-2 :
        if A[i-1]<=A[i] :
            continue
        elif A[i-1]>A[i] :
            kabu+=money//A[i]
            money-=A[i]*(money//A[i])

    if A[i]<A[i+1] and money>=A[i] : #株を買う
        kabu+=money//A[i]
        money-=A[i]*(money//A[i])

    elif A[i]>A[i+1] and kabu>0 :    #株を売る
        if A[i+1]>=A[i+2] :          #下がり続けていれば何もしない
            continue
        elif A[i+1]<A[i+2] :
            money+=kabu*A[i]
            kabu=0

else :
    money+=kabu*A[n-1]
    print(money)
    

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

money=1000
stock=0

for i in range(N-1) :
    if A[i]<A[i+1] :
        stock=money//A[i]
        money-=stock*A[i]
        money+=stock*A[i+1]

    else :
        continue

print(money)

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

for i in range(N-1,0,-1) :
    if A[i-1]>A[i] :
        A.pop(i)

if len(A)==1 :
    print(1000)
    exit()

n=len(A)
money=1000
kabu=0


for i in range(n-1) : 
    if i==n-2 :
        if A[i-1]<=A[i] :
            continue
        elif A[i-1]>A[i] :
            kabu+=money//A[i]
            money-=A[i]*(money//A[i])

    if A[i]<A[i+1] and money>=A[i] : #株を買う
        kabu+=money//A[i]
        money-=A[i]*(money//A[i])

    elif A[i]>A[i+1] and kabu>0 :    #株を売る
        if A[i+1]>=A[i+2] :          #下がり続けていれば何もしない
            continue
        elif A[i+1]<A[i+2] :
            money+=kabu*A[i]
            kabu=0

else :
    money+=kabu*A[n-1]
    print(money)
    

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

money=1000
stock=0

for i in range(N-1) :
    if A[i]<A[i+1] :
        stock=money//A[i]
        money-=stock*A[i]
        money+=stock*A[i+1]

    else :
        continue

print(money)