n=int(eval(input()))

a=[None]*n

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

a[0]=b[0]

a[-1]=b[-1]

for i in range(1,n-1):

    if b[i]>=b[i-1]:

        a[i]=b[i-1]

    else:

        a[i]=b[i]

print((sum(a)))
n=int(eval(input()))

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

a=[0]*n

a[0]=b[0]

for i in range(n-2):

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

a[-1]=b[-1]

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

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

-a = [None] * n +a = [0] * n +for i in range(n - 2): +    a[i + 1] = min(b[i], b[i + 1]) -for i in range(1, n - 1): -    if b[i] >= b[i - 1]: -        a[i] = b[i - 1] -    else: -        a[i] = b[i]