Problem p02917 (python)

Fixed submission:
n = int(input())
alist=list(map(int,input().split()))
alist.insert(0,1e7)
alist.append(1e7)
core = 0
for i in range(n):
  core +=min(alist[i],alist[i+1])
print(core)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
mina = min(alist[0],alist[1])
minb = min(alist[-2],alist[-1])
minc = alist[-1]
core = 0
for i in range(n-3):
  core +=min(alist[i],alist[i+1],alist[i+2])
print(core + mina + minb + minc)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
min1 = min(alist[0],alist[1])
min2 = min(alist[-2],alist[-1])
last = alist[-1]
core = 0
for i in range(n-3):
  core +=min(alist[i],alist[i+1],alist[i+2])
print(core + min1 + min2 + last)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(n-3):
  core +=min(alist[i],alist[i+1],alist[i+2])
min1 = min(alist[0],alist[1])
min2 = min(alist[-2],alist[-1])
print(core + min1 + min2 + alist[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(n-3):
  core +=min(alist[i],alist[i+1],alist[i+2])
print(core+min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(n-3):
  core +=min(alist[i],alist[i+1],alist[i+2])
print(core+min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(n-2):
  core +=min(alist[i],alist[i+1],alist[i+2])
print(core +min(alist[-2],alist[-1]) +alist[-1]) +min(alist[0],alist[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(1,n-3):
  core +=int(min(alist[i-1],alist[i],alist[i+1]))
print(int(core) +int(min(alist[-2],alist[-1])) +int(alist[-1]) +int(min(alist[0],alist[1])))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = []
for i in range(1,n-3):
  core +=min(alist[i-1],alist[i],alist[i+1])
print(sum(core) +int(min(alist[-2],alist[-1])) +int(alist[-1]) +int(min(alist[0],alist[1])))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(1,n-3):
  core +=min(alist[i-1],alist[i],alist[i+1])
print(core +min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(1,n-2):
  core +=min(alist[i-1],alist[i],alist[i+1])
print(core +min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(1,n-1):
  core +=min(alist[i-1],alist[i],alist[i+1])
print(core +min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
print(sum(min(alist[i-1],alist[i],alist[i+1]) for i in range(1,n-1))\
      +min(alist[-2],alist[-1])+alist[-1]+min(alist[0],alist[1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist=list(map(int,input().split()))
print(sum(min(alist[i-1],alist[i],alist[i+1]) for i range(1,n-1))\
      +min(alist[-2],alist[-1])+alist[-1]+min(alist[0],alist[1]))