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.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq N \leq 100
 - 0 \leq B_i \leq 10^5

-----Input-----
Input is given from Standard Input in the following format:
N
B_1 B_2 ... B_{N-1}

-----Output-----
Print the maximum possible sum of the elements of A.

-----Sample Input-----
3
2 5

-----Sample Output-----
9

A can be, for example, ( 2 , 1 , 5 ), ( -1 , -2 , -3 ), or ( 2 , 2 , 5 ). Among those candidates, A = ( 2 , 2 , 5 ) has the maximum possible sum.

Difficulty: introductory

Starter code:

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

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

N = int(input())
B = list((int(x) for x in input().split()))
A1 = B + [100001]
A2 = [100001] + B
A = [min(A1[i],A2[i]) for i in range(N)]
print(sum(A))

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

tmp = B[0]
ans = 0
B.append(B[-1])
for b in B:
    ans += min(tmp, b)
    tmp = b
print(ans)

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



N=int(input())
B=list(map(int, input().split()))
ans=B[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()))
A=[0]*N
for i in range(N):
    A[i]=B[i-1]
    if A[i-1]>B[i-1]:
        A[i-1]=B[i-1]
A[0]=B[0]
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],b[i-1])

print(sum(a))

n = int(input())
#a, b = map(int, input().split())
bl = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]

al = [0]*n
al[-1] = bl[-1]
for i in range(n-2, -1, -1):
    if bl[i] < al[i+1]:
        al[i+1] = bl[i]
    al[i] = bl[i]
print((sum(al)))


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

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

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

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

print(ans)


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

N = int(input())
B_ls = [float('inf')] + list(map(int, input().split(' '))) + [float('inf')]
A_ls = []
for i in range(N):
    A_ls.append(min(B_ls[i], B_ls[i + 1]))
print(sum(A_ls))

#nは数列Aの長さ　Bの長さはn-1
n = int(input())
bn = list(map(int,input().split()))

an =[bn[0]]


for x in range(n-2):
    if bn[x+1] >= bn[x] :
        an.append(bn[x])
    else:
        an.append(bn[x+1])

an.append(bn[-1])

print(sum(an))

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

ans = []

for (i, ele) in enumerate(arr):
    if i == 0:
        ans.append(ele)
    else:
        ans.append(min(arr[i - 1], arr[i]))
    if i == len(arr) - 1:
        ans.append(arr[-1])
print((sum(ans)))


N = int(input())
A_ls = []
B_ls = [float('inf')] + list(map(int, input().split(' '))) + [float('inf')]
for i in range(N):
    A_ls.append(min(B_ls[i], B_ls[i + 1]))
print(sum(A_ls))

N = int(input())
B = [int(b) for b in input().split()]
A = [0] * N
A[0] = B[0]
A[1] = B[0]
for i in range(N-1):
  if B[i] >= max(A[i], A[i]):
    A[i+1] = B[i]
  else:
    A[i] = B[i]
    A[i+1] = B[i]
print(sum(A))

n = int(input())
A = [0]*n
B = list(map(int,input().split()))

A[0] = B[0]
A[-1] = B[-1]
for i in range(1,n-1):
  A[i] = min(B[i-1],B[i])
print(sum(A))

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

N = int(input())
B = input().split()

ans = 0

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

print(ans)

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

n = int(input())
b = [10**6] + list(map(int, input().split())) + [10**6]

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

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

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

print(result)

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


#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n = int(input())
    numbers= list(map(int,input().split()))
    dp=[0]*n

    dp[0]=numbers[0]
    dp[-1]=numbers[-1]

    for i in range(1,n-1):
        dp[i]=min(numbers[i-1],numbers[i])
    print(sum(dp))

def __starting_point():
    main()
__starting_point()

# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 16:47:54 2020

@author: liang
"""
INF = 10**6
N = int(input())
B = [INF]+list(map(int,input().split()))+[INF]

ans = 0

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

print(ans)

N = int(input())
B = list(map(int, input().split()))
 
# A_1 <= B_1
# A_2 <= min(B_1, B_2)
# A_3 <= min(B_2, B_3)
# A_(N-1) <= min(B_(N-2), B_(N-1))
# A_N <= B_(N-1)
# ans = B_1 + min(B_1, B_2) + ... + min(B__(N-2), B_(N-1)) + B_(N-1)
 
ans = B[0] + B[N-2]
for i in range(1, N-1):
  ans += min(B[i-1], B[i])

print(ans)

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

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

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

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

print(sum(a))

N = int(input())
B = list(map(int, input().split(' ')))
A = [ [] for i in range(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(sum(A))

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

a =[b[0]]

for x in range(n-2):
  s = min(b[x],b[x+1])
  a.append(s)
  
a.append(b[-1])

print((sum(a)))


# coding: utf-8


def main():
    N = int(input())
    ans = 0
    B = list(map(int, input().split()))
    ans += B[0] + B[-1]

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

    print(ans)

def __starting_point():
    main()

__starting_point()

N = int(input())
li = list(map(int, input().split()))
rli = li[::-1]
rli.append(100001)
ans = [0] * N

ans[0] = rli[0]
for i in range(0, len(li)):
    ans[i+1] = min(rli[i], rli[i+1])

#print(ans)
print(sum(ans))

n = int(input())
B = list(map(int, input().split()))
ans = [B[0]]
for i in range(len(B)):
    if i != len(B)-1:
        if B[i] > B[i+1]:
            ans.append(B[i+1])
        else:
            ans.append(B[i])
    else:
        ans.append(B[i])
print(sum(ans))

n = int(input())
alist=list(map(int,input().split()))
alist.insert(0,1e7)
alist.append(1e7)
core = 0
for i in range(n):
  core +=min(alist[i],alist[i+1])
print(core)

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

A[0] = B[0]
A[-1] = B[-1]

for n in range(1,N-1):
  A[n] = min(B[n-1],B[n])
  
print(sum(A))

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

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    B = inl()
    A = [None] * n
    A[0] = B[0]
    for i in range(1, n - 1):
        A[i] = min(B[i - 1], B[i])
    A[n - 1] = B[n - 2]
    return sum(A)


print(solve())


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

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

A = [0]*n
A[0] = B[0]
A[n-1] = B[n-2]

if n >= 3:
    for i in range(1, n-1):
        A[i] = min(B[i], B[i-1])

print((sum(A)))


N = int(input())
B = list(map(int, input().split()))
A = [B[0], B[0]]
for i in range(1, N-1):
    b = B[i]
    A.append(b)
    a = max([A[i],A[i+1]])
    if a > b:
        A[A.index(a)] = b
print((sum(A)))


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

A = [0] * N
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((sum(A)))


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

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

ans += B[-1]

print(ans)


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


# import math
# import statistics
# import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# N,K= map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(N)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
ans=[f[0],f[-1]]
for i in range(a-2):
    ans.append(min(f[i],f[i+1]))

print(sum(ans))

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

res = 0

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

print(res + B[0] + B[-1])

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

a_list = [0]*n
a_list[0] = num_list[0]

for i in range(1, n, 1):
	if i != n-1:
		a_list[i] = min(num_list[i-1], num_list[i])
	else:
		a_list[i] = num_list[-1]

sum = 0
for j in a_list:
	sum += j

print(sum)

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

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

#端点
cnt += (B[0]+B[N-2])
print(cnt)

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

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

print(sum(al))

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

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

A[0] = B[0]
A[N-1] = B[N-2]

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

N = int(input())
B_ls = [float('inf')] + list(map(int, input().split(' '))) + [float('inf')]
A_ls = []
for i in range(N):
    A_ls.append(min(B_ls[i], B_ls[i + 1]))
print(sum(A_ls))

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

N = int(input())
A = [int(x) for x in input().split()]
B = [A[0]]

for i in range(len(A)):
    if(B[i] > A[i]):B[i] = A[i]
    B.append(A[i])
print(sum(B))

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


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

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

# ABC 140 C
N = int(input())
B = [int(i) for i in input().split()]
ans = B[0] + B[-1]
if N >= 3:
    for i in range(0, N-2):
        ans += min(B[i], B[i+1])

print(ans)

N = int(input())
B_ls = [float('inf')] + list(map(int, input().split(' '))) + [float('inf')]
A_ls = []
for i in range(N):
    A_ls.append(min(B_ls[i], B_ls[i + 1]))
print(sum(A_ls))

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

# A_1 <= B_1
# A_2 <= min(B_1, B_2)
# A_3 <= min(B_2, B_3)
# A_(N-1) <= min(B_(N-2), B_(N-1))
# A_N <= B_(N-1)
# ans = B_1 + min(B_1, B_2) + ... + min(B__(N-2), B_(N-1)) + B_(N-1)
 
ans = 0
for i in range(N):
  if i == 0: ans += B[0]
  elif i == N-1: ans += B[N-2]
  else: ans += min(B[i-1], B[i])

print(ans)

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

N = int(input())
B_ls = [float('inf')] + list(map(int, input().split(' '))) + [float('inf')]
A_ls = []
for i in range(N):
    A_ls.append(min(B_ls[i], B_ls[i + 1]))
print(sum(A_ls))

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

list_a= [bs[0]]

for i in range(1,len(bs)):
    a = min(bs[i-1],bs[i])
    list_a.append(a)
    
list_a.append(bs[len(bs)-1])

print((sum(list_a)))


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

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

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

print(sum(A))

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

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

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

print(A)    

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

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

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

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

ans = 0
last_n = 0
for i in l:
    if i >= last_n:
        ans += i
        last_n = i
    else:
        ans -= last_n
        ans += i*2
        last_n = i
ans += l[0]
print(ans)

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

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

# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 16:47:54 2020

@author: liang
"""
N = int(input())
B = list(map(int,input().split()))

ans = B[0]

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

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

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


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



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

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

print(sum(A))

N = int(input())
A = [int(x) for x in input().split()]
B = [A[0]]

for i in range(len(A)):
    if(B[i] > A[i]):B[i] = A[i]
    B.append(A[i])
print(sum(B))

N = int(input())
B_List = list(map(int,input().split()))
A_List = [[] for i in range(N)]
A_List[0] = B_List[0]
A_List[1] = B_List[0]
for i in range(1,N - 1):
    if B_List[i] <= B_List[i-1]:
        A_List[i] = B_List[i]
    A_List[i+1] = B_List[i]
        
        

print(sum(A_List))

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

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

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    B = LI()
    ans = B[-1]+B[0]
    for i in range(N-2):
        ans += min(B[i], B[i+1])
    print(ans)
        
        
    
def __starting_point():
    main()
__starting_point()

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

ans = []

for (i, ele) in enumerate(arr):
    if i == 0:
        ans.append(ele)
    else:
        ans.append(min(arr[i - 1], arr[i]))
    if i == len(arr) - 1:
        ans.append(arr[-1])
print((sum(ans)))


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

B = B[::-1]
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i >= N - 1:
    A.append(B[i-1])
  else:
    a = min(B[i],B[i-1])
    A.append(a)
    
print(sum(A))

N = int(input())
ls = [int(i) for i in input().split()]
if len(ls) == 1:
  print(ls[0]*2)
else:
  als = [ls[0]]
  for n in range(1, N-1):
    als.append(min(ls[n-1], ls[n]))
  als.append(ls[-1])
  print(sum(als))

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

a.append(b[0])
for i in range(1,n-1) :
  if b[i-1] < b[i] :
    a.append(b[i-1])
  else :
    a.append(b[i])
a.append(b[n-2])  
print(sum(a))

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

result = 0
tmp = 0
for i in B:
    result += min(tmp, i)
    tmp = i

result += B[0] + B[-1]

print(result)

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

A = [0] * N

A[0] = B[0]
A[-1] = B[-1]

for i in range(1, N-1):
    A[i] = B[i-1]

    if A[i] > B[i]:
        A[i] = B[i]
    
print(sum(A))

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

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

print(ans)


n = int(input())
bn = [int(num) for num in input().split()]
 
an = [0]*n
an[0] = bn[0]
an[n-1] = bn[n-2]
for i in range(1,n-1):
    s = min(bn[i],bn[i-1])
    an.append(s)
    
print(sum(an))

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

N = int(input())
A = []
B = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if(i == 0):
        A.append(B[0])
        continue
    if(i == N-1):
        A.append(B[N-2])
        continue
    a = B[i-1]
    b = B[i]
    if(a < b):
        A.append(a)
    else:
        A.append(b)
for i in A:
    ans += i
print(ans)

import math
import collections
import itertools

def resolve():

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

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


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]))

A.append(B[-1])

print((sum(A)))


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

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

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

print(sum(A))

# C

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