100 atcoder#ABC140C. [ABC140C] Maximal Value

[ABC140C] Maximal Value

Score : 300300 points

Problem Statement

There is an integer sequence AA of length NN whose values are unknown.

Given is an integer sequence BB of length N1N-1 which is known to satisfy the following:

Bimax(Ai,Ai+1)B_i \geq \max(A_i, A_{i+1})

Find the maximum possible sum of the elements of AA.

Constraints

  • All values in input are integers.
  • 2N1002 \leq N \leq 100
  • 0Bi1050 \leq B_i \leq 10^5

Input

Input is given from Standard Input in the following format:

NN

B1B_1 B2B_2 ...... BN1B_{N-1}

Output

Print the maximum possible sum of the elements of AA.

3
2 5
9

AA can be, for example, ( 22 , 11 , 55 ), ( 1-1 , 2-2 , 3-3 ), or ( 22 , 22 , 55 ). Among those candidates, AA = ( 22 , 22 , 55 ) has the maximum possible sum.

2
3
6
6
0 153 10 10 23
53