n = int(eval(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], b[i - 1])



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

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



a = [-1] * n



for i, b in enumerate(B):

    if a[i] > B[i]:

        a[i] = b

        a[i+1] = b

    elif a[i] != -1:

        a[i+1] = b

    elif a[i] == -1:

        a[i] = b

        a[i+1] = b



print((sum(a)))
n = int(eval(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], b[i - 1])
print((sum(a)))

n = int(eval(input()))
B = list(map(int, input().split()))
a = [-1] * n
for i, b in enumerate(B):
    if a[i] > B[i]:
        a[i] = b
        a[i + 1] = b
    elif a[i] != -1:
        a[i + 1] = b
    elif a[i] == -1:
        a[i] = b
        a[i + 1] = b
print((sum(a)))

-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], b[i - 1]) +B = list(map(int, input().split())) +a = [-1] * n +for i, b in enumerate(B): +    if a[i] > B[i]: +        a[i] = b +        a[i + 1] = b +    elif a[i] != -1: +        a[i + 1] = b +    elif a[i] == -1: +        a[i] = b +        a[i + 1] = b