TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
import numpy as np
N = input()
N = int(N)
B = np.hstack([int(a) for a in input().split()])

A = np.zeros(N)
A[0] = B[0]
A[-1] = B[-1]
for i in range(N-2):
  A[i+1] = min(B[i], B[i+1])
               
print(np.sum(A))

import numpy as np
N = input()
N = int(N)
B = np.hstack([int(a) for a in input().split()])

A = np.zeros(N)
A[0] = B[0]
A[-1] = B[-1]
for i in range(N-2):
  A[i+1] = min(B[i], B[i+1])
               
print(int(np.sum(A)))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))
a = b[0] + b[len(b) -1]
for i in range(1,len(b)):
    a += min(b[i-1], b[i])
    print(min(b[i-1], b[i]))
print(a)

n = int(input())
b = list(map(int, input().split()))

a = b[0] + b[len(b) -1]
for i in range(1,len(b)):
    a += min(b[i-1], b[i])
print(a)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
b = [10**9] + list(map(int,input().split())) + [10**9]
a = []
a[0] = b[1]
for i in range(1,N-1):
  a[i] == min(b[i-1],b[i])
  
a[N] = b[N-1]

N = int(input())
b = [10**9] + list(map(int,input().split())) + [10**9]
a = []

for i in range(N):
  a.append(min(b[i],b[i+1]))

print(sum(a))


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))
a = [0] * n
for i in range(1,n-1):
         a[i] = min(b[i],b[i-1])
         print(a[i])
a[0] = b[0]
a[n-1] = b[n-2]
print(sum(a))


n = int(input())
b = list(map(int,input().split()))
a = [0] * n
for i in range(1,n-1):
         a[i] = min(b[i],b[i-1])
a[0] = b[0]
a[n-1] = b[n-2]
print(sum(a))


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
# ABC140C

n = int(input()) - 1
b = list(map(int, input().split()))

max_value = b[0] + b[n - 1]
for i in range(n - 1):
    max_value += min(b[i], b[i + 1])


n = int(input())
b = list(map(int, input().split()))

max_value = b[0] + b[n - 2]
for i in range(n - 2):
    max_value += min(b[i], b[i + 1])
print(max_value)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
arr = [int(item) for item in input().split()]

ans = arr[-1]
for i in range(N-2):
    ans += min(arr[i], arr[i+1])

print(ans)


N = int(input())
arr = [int(item) for item in input().split()]

ans = arr[-1] + arr[0]
for i in range(N-2):
    ans += min(arr[i], arr[i+1])

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
lis = list(map(int, input().split()))
print(lis)
result = []
result.append(lis[0])
for i in range(N-2):
    result.append(min(lis[i], lis[i+1]))
result.append(lis[N-2])
print(sum(result))

N = int(input())
lis = list(map(int, input().split()))
result = []
result.append(lis[0])
for i in range(N-2):
    result.append(min(lis[i], lis[i+1]))
result.append(lis[N-2])
print(sum(result))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))
a = [0]*n
a[0] = b[0]
if len(b) == 1:
    print(2*sum(b))
for i in range(1, n-1):
    if b[i] <= b[i - 1]:
        a[i] = b[i]
    else:
        a[i] = b[i - 1]
    a[i + 1] = b[i]
print(a)    

n = int(input())
b = list(map(int, input().split()))
a = [0]*n
a[0] = b[0]
if len(b) == 1:
    print(2*sum(b))
else:
    for i in range(1, n-1):
        if b[i] <= b[i - 1]:
            a[i] = b[i]
        else:
            a[i] = b[i - 1]
        a[i + 1] = b[i]
    print(sum(a)) 

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))

ans = [b[0]]

for i in range(n-2):
    if b[i] <= b[i+1]:
        ans.append(b[i])
    else:
        ans.append(b[i+1])

ans.append(b[len(b)-1])

print(ans)

n = int(input())
b = list(map(int, input().split()))

ans = [b[0]]

for i in range(n-2):
    if b[i] <= b[i+1]:
        ans.append(b[i])
    else:
        ans.append(b[i+1])

ans.append(b[len(b)-1])

print(sum(ans))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))

dp = [10**8]*# NOTE:

for i in range(n-1):
    if dp[i] > b[i] :
        dp[i] = b[i]
    if dp[i+1] > b[i] :
        dp[i+1] = b[i]

print(sum(dp))


n = int(input())
b = list(map(int,input().split()))

dp = [10**8]*n

for i in range(n-1):
    if dp[i] > b[i] :
        dp[i] = b[i]
    if dp[i+1] > b[i] :
        dp[i+1] = b[i]

print(sum(dp))


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int ( input() )
c = list( map( int, input().split() ) )
ans_list = [ c[0] ]
for i in range( N - 2 ):
    ans_list.append( min(c[i], c[i+1]) )
ans_list.append( c[N-2] )
sum( ans_list )


N = int ( input() )
check_list = list( map( int, input().split() ) )
ans_list = [ check_list[0] ]
for i in range( N - 2 ):
    ans_list.append( min(check_list[i], check_list[i+1]) )
ans_list.append( check_list[N-2] )
sum( ans_list )

N = int ( input() )
check_list = list( map( int, input().split() ) )
ans_list = [ check_list[0] ]
for i in range( N - 2 ):
    ans_list.append( min(check_list[i], check_list[i+1]) )
ans_list.append( check_list[N-2] )
sum( ans_list )

N = int ( input() )
c = list( map( int, input().split() ) )
ans_list = [ c[0] ]
for i in range( N - 2 ):
    ans_list.append( min(c[i], c[i+1]) )
ans_list.append( c[N-2] )
print( sum( ans_list ) )


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())

B_lst = list(map(int,input().split()))
A_lst = [0] * n

for i in range(n-2):
    if B_lst[i+1] > B_lst[i]:
        A_lst[i] = B_lst[i]
    else:
        A_lst[i] = B_lst[i+1]

if B_lst[n-3] > B_lst[n-2]:
    A_lst[n-2] = B_lst[n-2]
else:
    A_lst[n-2] = B_lst[n-3]

A_lst[n-1] = B_lst[n-2]
print(A_lst)
print(sum(A_lst))


n = int(input())

B_lst = list(map(int,input().split()))
A_lst = [0] * n

for i in range(n-1):
    if B_lst[i] > B_lst[i-1]:
        A_lst[i] = str(B_lst[i-1])
    else:
        A_lst[i] = str(B_lst[i])

    if i == n-2:
        A_lst[i+1] = str(B_lst[i])
        break

list = ' '.join(A_lst)
print(list)


n = int(input())

B_lst = list(map(int,input().split()))
A_lst = [0] * (n+1)

for i in range(n):
    if B_lst[i] > B_lst[i-1]:
        A_lst[i] = str(B_lst[i-1])
    else:
        A_lst[i] = str(B_lst[i])

    if i == n-1:
        A_lst[i+1] = str(B_lst[i])
        break

list = ' '.join(A_lst)
print(list)


n = int(input())

B_lst = list(map(int,input().split()))
A_lst = [0] * n

A_lst[0] = B_lst[0]
A_lst[n-1] = B_lst[n-2]

if n >= 3:
    for i in range(1,n-1):

        if B_lst[i-1] > B_lst[i]:
            A_lst[i] = B_lst[i]
        else:
            A_lst[i] = B_lst[i-1]

print(sum(A_lst))


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
blist=list(map(int,input().split()))
alist=[]
for i in range(n-2):
    alist.append(min(blist[i],blist[i+1]))
alist.append(blist[n-2])
gokei=sum(alist)
print(gokei)

n=int(input())
if n!=2:
    blist=list(map(int,input().split()))
    alist=[]
    for i in range(n-2):
        alist.append(min(blist[i],blist[i+1]))
    alist.append(blist[n-2])
    gokei=sum(alist)
    print(gokei)
else:
    b=int(input())
    print(int(b*2))

n=int(input())
if n!=2:
    blist=list(map(int,input().split()))
    alist=[blist[0]]
    for i in range(1,n-1):
        alist.append(min(blist[i],blist[i-1]))
    alist.append(blist[n-2])
    gokei=sum(alist)
    print(gokei)
else:
    b=int(input())
    print(int(b*2))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int,input().split()))
# B.reverse()

sum = 0
# tmp = B[0]

for i in range(N-2):
    sum += min(B[i],B[i+1])
sum += B[N-2]

print(sum)


N = int(input())
B = list(map(int,input().split()))

sum = 0

for i in range(N-2):
    sum += min(B[i],B[i+1])
sum += B[N-2] + B[0]

print(sum)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
a = map(int,input().split())
s = 0
for i in range(n-2):
  s+=min(a[n-2-i],a[n-i-3])
print(s+a[n-2])


n = int(input())
a = map(int,input().split())
s = 0
for i in range(n-2):
  s+=min(a[n-i],a[n-i-1])
print(s+a[n-2])

n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n-2):
  s+=min(a[n-2-i],a[n-i-3])
print(s+a[n-2]+a[0])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())

B = list(map(int,input().split()))
sum = 0
if n == 2:
  sum = B[0]
else:
  for i in range(n-2):
    sum += min(B[i],B[i+1])
  
sum += B[n-2]
print(sum)

n = int(input())

B = list(map(int,input().split()))
sum = B[0]
for i in range(n-2):
  sum += min(B[i],B[i+1])
  
sum += B[n-2]
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))

a = [b[0], b[n-2]]

for i in range(n-2) :
  a.append(min(b[i], b[i+1]))
  
print(a)
 
 

n = int(input())
b = list(map(int, input().split()))

a = [b[0], b[n-2]]

for i in range(n-2) :
  a.append(min(b[i], b[i+1]))
  
print(sum(a))
 
 

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())

B = [int(i) for i in input().split()]

ans = B[0] + B[N-1]

for i in range(1,N):
    ans+=min(B[i],B[i-1])
    
print(ans)

N = int(input())

B = [int(i) for i in input()split()]

ans = B[0] + B[N-1]

for i in range(1,N):
    ans+=min(B[i],B[i-1])
    
print(ans)

N = int(input())

B = [int(i) for i in input().split()]

ans = B[0] + B[N-2]

for i in range(1,N-1):
    ans+=min(B[i],B[i-1])
    
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
r = 0
for i, j in enumerate(a):
    r += b[j - 1]
    if a[i - 1] == a[i] - 1 and i > 0:
        r += c[j - 2]
print(r)


n = int(input())
li = list(map(int, input().split()))
r = li[0] + li[-1]
for i, j in enumerate(li):
    if i != len(li)-1:
        r += min(j, li[i + 1])
print(r)


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
b=[int(x) for x in input().split()]
a=[0]*n
for i in range(n-1):
	if(i==0):
		a[0]=b[0]
		a[1]=b[1]
    else:    
      if(b[i]>=b[i-1]):
          a[i+1]=b[i]
      if(b[i]<b[i-1]):		
          a[i]=b[i]
          a[i+1]=b[i]
print(sum(a))

n=int(input())
b=[int(x) for x in input().split()]
a=[0]*n
for i in range(n-1):
	if(i==0):
		a[0]=b[0]
		a[1]=b[1]
	elif(b[i]>=b[i-1]):
		a[i+1]=b[i]
	elif(b[i]<b[i-1]):		
		a[i]=b[i]
		a[i+1]=b[i]
print(sum(a))

n=int(input())
b=[int(x) for x in input().split()]
a=[0]*n
for i in range(n-1):
	if(i==0):
		a[0]=b[0]
		a[1]=b[0]
	else:	
		if(b[i]>=b[i-1]):
			a[i+1]=b[i]
		if(b[i]<b[i-1]):		
			a[i]=b[i]
			a[i+1]=b[i]
print(sum(a))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = []
B = list(map(int, input().split()))

A = 0

for i in range(len(B)+1):
    if i == 0:
        A += B[0]
    elif i < len(B):
        print(i, B[i-1], B[i])
        A += min(B[i-1], B[i])
    else:
        A += B[i-1]
        
print(A)

N = int(input())
B = []
B = list(map(int, input().split()))

A = 0

for i in range(N):
    if i == 0:
        A += B[0]
    elif i < len(B):
#         print(i, B[i-1], B[i])
        A += min(B[i-1], B[i])
    elif i == N-1:
        A += B[i-1]
        
print(A)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N=int(input())
B=list(map(int,input().split()))
ans=0
ans+=B[0]+B[-1]
for i in range(N-1):
  ans+=min(B[i],B[i+1])
print(ans)

N=int(input())
B=list(map(int,input().split()))
ans=0
ans+=B[0]+B[-1]
for i in range(N-2):
  ans+=min(B[i],B[i+1])
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))
a = [0] *n
a[0]=b[0]
for i in range(0,n-2):
    a[i+1] = min([b[i],b[i+1]])
    print([b[i],b[i+1]])
    # if a[n-1-i] <= b[n-2-i]:
    #     a[n-2-i] = b[n-2-i]
    # else:
    #     a[n-1-i] = b[n-2-i]
    #     a[n-2-i] = b[n-2-i]
a[n-1] = b[n-2]
print(sum(a))

n = int(input())
b = list(map(int,input().split()))
ans = 0
for i in range(n-2):
    if b[i] <= b[i+1]:
        ans = ans + b[i]
    else:
        ans = ans + b[i+1]
print(ans+b[n-2])

    n = int(input())
    b = list(map(int,input().split()))
    a = [0] *n
    for i in range(0,n-2):
        a[i+1] = min([b[i],b[i+1]])
    a[0] =a[1]
    a[n-1] = b[n-2]
    print(sum(a))

n = int(input())
b = list(map(int,input().split()))
a = [0] *n
for i in range(0,n-2):
    a[i+1] = min([b[i],b[i+1]])
    print([b[i],b[i+1]])
    # if a[n-1-i] <= b[n-2-i]:
    #     a[n-2-i] = b[n-2-i]
    # else:
    #     a[n-1-i] = b[n-2-i]
    #     a[n-2-i] = b[n-2-i]
a[0] =a[1]
a[n-1] = b[n-2]
print(sum(a))

n = int(input())
b = list(map(int,input().split()))
a = [0] *n
for i in range(0,n-2):
    a[i+1] = min([b[i],b[i+1]])
    # if a[n-1-i] <= b[n-2-i]:
    #     a[n-2-i] = b[n-2-i]
    # else:
    #     a[n-1-i] = b[n-2-i]
    #     a[n-2-i] = b[n-2-i]
a[0] =b[0]
a[n-1] = b[n-2]
print(sum(a))


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for num, i in enumerate(b[:]):
  if num == 0:
    a.append(i)
  elif num == n-2:
    a.append(i)
  elif i <= b[num + 1]:
    a.append(i)
  elif i > b[num + 1]:
    a.append(b[num + 1])
print(sum(a))
print(a)


n = int(input())
b = list(map(int, input().split()))

a = list()
for num, i in enumerate(b[:]):
  if num == 0:
    a.append(0)
    a.append(0)
  elif num == n-2:
    a.append(i)
  elif i > b[num + 1]:
    a.append(b[num + 1])
  elif i <= b[num + 1]:
    a.append(i)
print(sum(a))


n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for num, i in enumerate(b[:-1]):
  if num == 0:
    a.append(i)
  elif num == n-2:
    a.append(i)
  elif i <= b[num + 1]:
    a.append(i)
  elif i > b[num + 1]:
    a.append(b[num + 1])
print(sum(a))


n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for num, i in enumerate(b):
  if num == 0:
    a.append(i)
  elif num == n-2:
    a.append(i)
  elif i <= b[num + 1]:
    a.append(i)
  elif i > b[num + 1]:
    a.append(b[num + 1])
print(sum(a))
print(a)

n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for num, i in enumerate(b[1:]):
  a.append(min(i, b[num]))
a.append(b[-1])
print(sum(a))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
import numpy as np
N = int(input())
B = list(map(int, input().split())) 
A=np.zeros([N])
for i in range(N):
    if i == 0:
        A[i] = B[i]
    elif i== N-1:
        A[i] = B[i-1]
    else:
        A[i] = min(B[i-1],B[i])

int(A.sum())
        

import math

N = int(input())
B = list(map(int, input().split())) 
import numpy as np
A=np.zeros([N])
for i in range(N):
    if i == 0:
        A[i] = B[i]
    elif i== N-1:
        A[i] = B[i-1]
    else:
        A[i] = min(B[i-1],B[i])

int(A.sum())
        

N = int(input())
A = list(map(int, input().split())) 
sum(A)+min(A)

import math

N = int(input())
B = list(map(int, input().split())) 
import numpy as np
A=np.zeros([N])
for i in range(N):
    if i == 0:
        A[i] = B[i]
    elif i== N-1:
        A[i] = B[i-1]
    else:
        A[i] = min(B[i-1],B[i])

print(int(A.sum()))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
l1[0]=l[0]
l1[1]=l[1]
for i in range(1,n-2):
  if l[i]>l[i+1]:
    l1[i]=l[i+1]
  l1[i+1]=l[i+1]
sum=0
for i in l1:
  sum+=i
print(sum)

n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
l1[0]=l[0]
l1[1]=l[0]
for i in range(0,n-2):
  if l[i]>l[i+1]:
    l1[i+1]=l[i+1]
  l1[i+2]=l[i+1]
sum=0
for i in l1:
  sum+=i
print(sum)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
b=list(map(int,input().split()))
a=[]
for i in b:
    for j in b:
        if i>=max(b[j],b[i]):
            a.append(max(b[j],b[j+1]))
print(sum(a))

n=int(input())
b=list(map(int,input().split()))

A=[]
for i in range(n):
    if i==0:
        A.append(b[0])
    elif i==n-1:
        A.append(b[-1])
    else:
        A.append(min(b[i],b[i-1]))
print(sum(A))

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
list_B = list(map(int, input().split()))
list_A = [0]*(len(list_B) + 1)

for i in reversed(range(len(list_B))):
    list_A[i + 1] = list_B[i]
    list_A[i] = list_B[i]

print(list_A)

n = int(input())
list_B = list(map(int, input().split()))
list_A = [0]*(len(list_B) + 1)

for i in reversed(range(len(list_B))):

    
    if list_B[i] < list_A[i + 1]:
        list_A[i + 1] = list_B[i]

    list_A[i] = list_B[i]


list_A[-1] = list_B[-1]

print(sum(list_A))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = input()
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,len(B)):
    A[i] = min(B[i-1],B[i])
    i += 1

A[N] = B[-1]

print(sum(A))


n = int(input())
b = list(map(int,input().split()))
a =[0]*n
a[0] = b[0]
a[-1] = b[-1]

for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])

total = sum(a)

print(total)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = [int(i) for i in input().split(' ')]
A = []
A.append(B[0])
for i in range(1,N-1):
    A.append(min(B[i],B[i-1]))
A.append(B[N-2])

N = int(input())
B = [int(i) for i in input().split(' ')]
A = []
A.append(B[0])
for i in range(1,N-1):
    A.append(min(B[i],B[i-1]))
A.append(B[N-2])
print(sum(A))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
b = list(map(int, input().split()))

count = b[0]
for i in range(1, N-2):
    count = count + min(b[i], b[i+1])
count = count + b[N-2]

print(count)

N = int(input())
b = list(map(int, input().split()))

count = b[0] + b[N-2]
for i in range(1, N-1):
    count = count + min(b[i-1], b[i])
print(count)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
# C - Maximal Value

N = int(input())
B = [int(b) for b in input().split()]

A = [0] * N
for i in range(N - 1):
    A[i + 1] = B[i]
    if B[i] < A[i]:
        A[i] = B[i]

print(sum(A))


# C - Maximal Value

N = int(input())
B = [int(b) for b in input().split()]

A = [float('inf')] * N
for i in range(N - 1):
    A[i + 1] = B[i]
    if B[i] < A[i]:
        A[i] = B[i]

print(sum(A))


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
# -*- coding: utf-8 -*-
N = int(input())
B = list(map(int,input().split()))
sum = 0

for i in range(N-1):
  if i == 0:
    sum += B[i]
  if i == N-2:
    sum += min(B[i-1], B[i])
    sum += max(B[i-1], B[i])
  else:
    sum += min(B[i-1], B[i])


print(sum)

# -*- coding: utf-8 -*-
N = int(input())
B = list(map(int,input().split()))
sum = 0

if N == 2:
  sum += B[0]
  sum += B[0]
else:
  for i in range(N-1):
    if i == 0:
      sum += B[i]
    if i == N-2:
      sum += min(B[i-1], B[i])
      sum += B[i]
    else:
      sum += min(B[i-1], B[i])

print(sum)

# -*- coding: utf-8 -*-
N = int(input())
B = list(map(int,input().split()))
sum = 0

if N == 2:
  sum += B[0]
else:
  for i in range(N-1):
    if i == 0:
      sum += B[i]
    else:
      sum += min(B[i-1], B[i])
sum += B[N-2]
print(sum)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
print(a)

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  a = a + b[n-1] + b[0]
print(a)

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i]>b[i+1]:
    a = a + b[i+1]

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
    a = a + b[n-1]
print(a)

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  a = a + b[n-1]
print(a)

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i]>b[i+1]:
    a = a + b[i+1]
print(a)

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  if b[i+1]==b[i]:
    a = a + b[i]
  a = a + b[n-1] + b[0]
print(a)

a=0
n = int(input())
b = list(map(int, input().split()))

for i in range(n-2):
  if b[i] >= b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  a = a + b[n-1] + b[0]
print(a)

n = int(input())
b = list(map(int, input().split()))
a_sum = 0

a_sum += b[0]

for i in range(n-2):
    if b[i] >= b[i+1]:
        a_sum += b[i+1]
    if b[i+1] > b[i]:
        a_sum += b[i]

a_sum += b[n-2]
print(a_sum)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
import numpy as np
N = int(input())
B = list(map(int, input().split()))
A = [0]*N
A[0]=min(B[0],B[1])
print(len(A),len(B))
for i in range(1,N-1):
    A[i]=min(B[i],B[i-1])
A[N-1]=B[N-2]
print(np.sum(A))

#c
import numpy as np
N = int(input())
B = list(map(int, input().split()))
A = [0]*N
if N>2:
    A[0]=B[0]
    for i in range(1,N-1):
        A[i]=min(B[i],B[i-1])
    A[N-1]=B[N-2]
    print(np.sum(A))
else:
    print(B[0]*2)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
b=[0]+list(map(int,input().split()))+[0]
a=[0]*n
for i in range(n):
  a[i]=min(b[i],b[i+1])
print(sum(a))

n=int(input())
b=[10**18]+list(map(int,input().split()))+[10**18]
a=[0]*n
for i in range(n):
  a[i]=min(b[i],b[i+1])
print(a)
print(sum(a))

n=int(input())
b=[10**18]+list(map(int,input().split()))+[10**18]
a=[0]*n
for i in range(n):
  a[i]=min(b[i],b[i+1])
print(sum(a))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int,input().split()))

A = B[1]

for i in range(N):
    if i >= 1:
        if B[i-1] >= B[i]:
          A += B[i-1]
        else:
          A += B[i]
print(A)

N = int(input())
B = list(map(int,input().split()))
A = B[i]

for i in range(N-1):
    if i >= 1:
       if B[i-1] >= B[i]:
         A += B[i-1]
       else:
         A += B[i]
print(A)

N = int(input())
B = list(map(int,input().split()))

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-1])


N = int(input())
B = list(map(int,input().split()))
A = B[1]

for i in range(N-1):
    if i >= 1:
       if B[i-1] >= B[i]:
         A += B[i-1]
       else:
         A += B[i]
print(A)

N = int(input())
B = list(map(int,input().split()))

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))
sum = 0
for i in range(n-1):
    if i == 0:
        sum += b[0]
        pass
    sum += min(b[i-1],b[i])
sum += b[-1]
print(sum)

n = int(input())
b = list(map(int,input().split()))
sum = 0
for i in range(1,n-1):
    sum += min(b[i-1],b[i])
sum += b[0]
sum += b[-1]
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int, input().split()))

ans = 0
for idx, val in enumerate(B):
    if idx == 1:
        ans += val
    else:
        ans += max(B[idx - 1], val)

print(ans)

N = int(input())
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if i == 0:
        ans += B[0]
    elif i == N - 1:
        ans += B[-1]
    else:
        ans += min(B[i - 1], B[i])

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
S = list(map(int, input().split()))
S = S[::-1]
S.append(S[-1])

for i in range(1, N):
    if S[i] <= S[i-1]:
        cnt += S[i]
    else:
        cnt += S[i-1]
        S[i] = S[i-1]

print(sum(S))



N = int(input())
S = list(map(int, input().split()))
S = S[::-1]

cnt = S[0]
for i in range(1, N-1):
    if S[i] <= S[i-1]:
        cnt += S[i]
    else:
        cnt += S[i-1]
        S[i] = S[i-1]
print(cnt)

N = int(input())
S = list(map(int, input().split()))
S = [10**5+1] + S + [10**5+1]
ans = []
for i in range(1, N+1):
    ans.append(min(S[i-1], S[i]))
print(sum(ans))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
a = []
sum_a = b[0] + b[-1]
for i,b_i in enumerate(b):
    
    if i+1 < n-1:
        if b[i+1] >= b[i]:
            a.append(b[i])
            sum_a += b[i]
        else:
            a.append(b[i+1])
            sum_a += b[i+1]
print(sum_a)

n = int(input())
b = input().split()
b = [int(i) for i in b] 

a = []
sum_a = b[0] + b[-1]
for i,b_i in enumerate(b):
    
    if i+1 < n-1:
        if b[i+1] >= b[i]:
            a.append(b[i])
            sum_a += b[i]
        else:
            a.append(b[i+1])
            sum_a += b[i+1]
print(sum_a)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())

B = [int(a) for a in input().split() ]

result = B[N-2]
old = B[N-2]
for i in range(N-3,-1,-1):
    print(min(B[i],old))
    result = result + min(B[i],old)
    old  = B[i]


result = result + B[0]

print(result)

N = int(input())

B = [int(a) for a in input().split() ]

result = B[N-2]
old = B[N-2]
for i in range(N-3,-1,-1):
    #print(min(B[i],old))
    result = result + min(B[i],old)
    old  = B[i]


result = result + B[0]

print(result)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))

res = 0

for i in range(1,n-2):
  if b[i] >= b[i+1]:
    res += b[i+1]
  else:
    res += b[i]
res += b[0]
res += b[n-2]
print(res)

n = int(input())
b = list(map(int,input().split()))

res = 0
count = 0

for i in range(1,n-2):
  if b[i] >= b[i+1]:
    res += b[i+1]
    count += 1
  else:
    res += b[i]
    count += 1
    
res += b[0]
res += b[n-2]
count += 2

if count == n:
  print(res)
else:
  while count < n:
     if b[0] >= b[1]:
      res += b[1]
      count += 1
     else:
       res += b[0]
       count += 1
  print(res)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N=int(input())
b=list(map(int,input().split()))
a=b[0]
for i in range(0,N-2):
    print(i)
    a+=min(b[i],b[i+1])
print(a+b[-1])


N=int(input())
b=list(map(int,input().split()))
a=[]
if N==2:
    a=[b[0]]*2
elif N>2:
    for i in range(N-2):
        minb=min(b[i],b[i+1])
        a.append(minb)
    a.append(b[-1])
print(sum(a))

N=int(input())
b=list(map(int,input().split()))
a=b[0]
for i in range(0,N-2):
    a+=min(b[i],b[i+1])
print(a+b[-1])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
B = list(map(int, input().split()))
tot = B[0]+B[-1]
for i in range(n-1):
  tot += min(B[i], B[i+1])
print(tot)

n = int(input())
B = list(map(int, input().split()))
tot = B[0]+B[-1]
for i in range(n-2):
  tot += min(B[i], B[i+1])
print(tot)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int,input().split()))
a = []
m = 0
if N == 2:
    print(B[0] * 2)
elif N == 3:
    print(B[0] + B[1] + min(B[0],B[1]))
else:

    for i in range(N - 1):
        if i == 0:
            a.append(B[i])
        elif i == N - 2:
            a.append(max(a[i - 1],B[i]))
        else:
            if max(B[i],B[i - 1]) <= B[i + 1]:
                a.append(B[i])
            else:
                a.append(B[i + 1])
    

for i in range(len(a)):
    m += a[i]
print(m)

N = int(input())
B = list(map(int,input().split()))
a = [0] * N
ans = 0
x = 0
if N == 2:
    ans = B[0] * 2
elif N == 3:
    ans = sum(B) + min(B)
else:
    for i in range(N - 1):
        if i == 0:
            a[0] = B[0]
            
        
        else:
            x = min(B[i],B[i - 1])
            a[i] = x
            
            if i == N - 2:
                a[i + 1] = B[N - 2]
                
        
        ans = sum(a)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
# coding: utf-8
# Your code here!

if __name__ == '__main__':
    n=int(input())
    a_list=[int(x)-1 for x in input().split()]
    b_list=[int(x) for x in input().split()]
    c_list=[int(x) for x in input().split()]
    score=sum(b_list)
    pre_a=-100
    for a in a_list:
        if(a-pre_a==1):
            score+=c_list[pre_a]
        pre_a=a
    print(score)
  

if __name__ == '__main__':
    n=int(input())
    a=[]
    b=[int(x) for x in input().split()]
    a.append(b[0])
    for i in range(n-2):
        a.append(min([b[i],b[i+1]]))
    a.append(b[-1])
    print(sum(a))
  

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
b=[int(i) for i in input().split()]
ans=b[-1]+b[0]
for i,j in z1p(b[:-1],b[1:]):
  ans+=min(i,j)
print(ans)

n=int(input())
b=[int(i) for i in input().split()]
ans=b[-1]+b[0]
for i,j in zip(b[:-1],b[1:]):
  ans+=min(i,j)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int, input().split()))
S = 0
temp = B[N-2]
for i in range(N):
    S += temp
    if N-i-3 >=0:
        if B[N-i-3] < B[N-i-2]:
            temp = B[N-i-3]
            
if N >2:
    if B[0] > B[1]:
        S = S + B[0] - B[1]   


N = int(input())
B = list(map(int, input().split()))
S = 0
temp = B[N-2]
for i in range(N):
    S += temp
    print(temp)
    if N-i-3 >=0:
        if B[N-i-3] < B[N-i-2]:
            temp = B[N-i-3]
            
if N >2:
    if B[0] > B[1]:
        S = S + B[0] - B[1]   

print(S)

N = int(input())
B = list(map(int, input().split()))
S = 0
temp = B[N-2]
for i in range(N):
    S += temp
    print(temp)
    if N-i-3 >=0:
        if B[N-i-3] < B[N-i-2]:
            temp = B[N-i-3]
            
if N >2:
    if B[0] > B[1]:
        S = S + B[0] - B[1]   

print(S)

N = int(input())
B = list(map(int, input().split()))
S = 0
temp = B[N-2]
for i in range(N):
    S += temp
    print(temp)
    if N-i-3 >=0:
        if B[N-i-3] < B[N-i-2]:
            temp = B[N-i-3]
        elif temp > B[N-i-2]:
            temp = B[N-i-2]

if N >2:
    if B[0] > B[1]:
        S = S + B[0] - B[1]   

print(S)

N = int(input())
B = list(map(int, input().split()))
S = 0

for i in range(N):
    if i == 0:
        S += B[0]
    elif i == N-1:
        S += B[N-2]
    else:
        S += min(B[i], B[i-1])

print(S)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))


ans = []
c = list(reversed(a))
for i, name in enumerate(c):
    if i == 0:
        ans.append(name)
    else:
        b = min(name, c[i-1])
        ans.append(b)

print(sum(ans))

n = int(input())
a = list(map(int, input().split()))

ans = [0]*(len(a) + 1)
for i, name in enumerate(a):
    if i == 0:
        ans[i] = name
        ans[i+1] = name
    else:
        ans[i] = min(name, a[i - 1])
        ans[i+1] = name

print(sum(ans))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
b=list(map(int,input().split()))
ans=0
a=[]
a.append(b[0])
for i in range(1,n):
  a.append(min(b[i-1],b[i]))
  
for i in range(n):
  ans+=a[i]
  
print(ans)

n=int(input())
b=list(map(int,input().split()))
ans=0
a=[]
a.append(b[0])
for i in range(1,n-1):
  a.append(min(b[i-1],b[i]))

a.append(b[n-2])
for i in range(n):
  ans+=a[i]
  
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int, input().split()))

max_val = B[0] + B[-1]
for i in range(1, N - 2):
    max_val += min(B[i], B[i + 1])

print(max_val)


N = int(input())
B = list(map(int, input().split()))

max_val = B[0] + B[-1]
for i in range(N - 2):
    max_val = min(B[i], B[i + 1])

print(max_val)


N = int(input())
B = list(map(int, input().split()))

max_val = B[0] + B[-1]
for i in range(1, N - 2):
    tmp = min(B[i], B[i + 1])
    max_val += tmp

print(max_val)


N = int(input())
B = list(map(int, input().split()))

max_val = B[0] + B[-1]
for i in range(N - 2):
    max_val += min(B[i], B[i + 1])

print(max_val)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))

#print(n)
#print(b)

score = b[0]+b[n-2]
#print(b[0],b[n-2])

for i in range(0,n-1):
	score = score + min(b[i],b[i+1])
#	print(min(b[i],b[i+1]))
print(score)

n = int(input())
b = list(map(int, input().split()))

#print(n)
#print(b)

score = b[0]+b[n-2]
#print(b[0],b[n-2])

for i in range(0,n-2):
	score = score + min(b[i],b[i+1])
#	print(min(b[i],b[i+1]))
print(score)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for i in range(n-2):
    a.append(min(b[i], b[i+1]))
    print(b[i])
a.append(b[len(b)-1])

print(sum(a))

n = int(input())
b = list(map(int, input().split())) 
a = [b[0]]

for i in range(n-2):
    a.append(min(b[i], b[i+1]))
    print(b[i])
a.append(b[len(b)-1])

print(sum(a))

n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for i in range(1, n-1):
    a.append(min(b[i-1], b[i]))
    print(b[i])
a.append(b[len(b)-1])

print(sum(a))

n = int(input())
b = list(map(int, input().split()))

a = [b[0]]
for i in range(1, n-1):
    a.append(min(b[i-1], b[i]))
a.append(b[len(b)-1])

print(sum(a))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  


print(ans+b[-1])

n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  

print(ans+b[-1]+b[0])

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input()) 
B = list(map(int, input().split()))
sum = B[0]
for i in range(0, N-1):
	sum += min(B[i],B[i-1])
sum += B[N-2]
print(sum)

N = int(input()) 
B = list(map(int, input().split()))
sum = B[0]
for i in range(1, N-1):
	sum += min(B[i],B[i-1])
sum += B[N-2]
print(sum)

Verdicts: Wrong Answer

Accepted