n=int(eval(input()))

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

b.reverse()



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)))
n=int(eval(input()))

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



c=0



c+=b[0]+b[-1]



for i in range(n-2):

    c+=min(b[i],b[i+1])



print(c)

n = int(eval(input()))
b = list(map(int, input().split()))
b.reverse()
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)))

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

-b.reverse() -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))) +c = 0 +c += b[0] + b[-1] +for i in range(n - 2): +    c += min(b[i], b[i + 1]) +print(c)