n = int(eval(input())); b = list(map(int, input().split())); summ = 0

for i in range(0, n-2):

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

summ = summ + b[0] + b[n-2]

print(summ)
N = int(eval(input()))

seqB = [int(x) for x in input().split()]



ai = aj = seqB[0]

seqA = [ai,aj]

for i in range(1, len(seqB)):

  aj = max(aj, seqB[i])

  if aj > seqB[i]: 

    aj = seqA[i] = seqB[i]

  seqA.append(aj)



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

N = int(eval(input()))
seqB = [int(x) for x in input().split()]
ai = aj = seqB[0]
seqA = [ai, aj]
for i in range(1, len(seqB)):
    aj = max(aj, seqB[i])
    if aj > seqB[i]:
        aj = seqA[i] = seqB[i]
    seqA.append(aj)
print((sum(seqA)))

-n = int(eval(input())) -b = list(map(int, input().split())) -summ = 0 -for i in range(0, n - 2): -    summ = summ + min(b[i], b[i + 1]) -summ = summ + b[0] + b[n - 2] -print(summ) +N = int(eval(input())) +seqB = [int(x) for x in input().split()] +ai = aj = seqB[0] +seqA = [ai, aj] +for i in range(1, len(seqB)): +    aj = max(aj, seqB[i]) +    if aj > seqB[i]: +        aj = seqA[i] = seqB[i] +    seqA.append(aj) +print((sum(seqA)))