AtCoder Beginner Contest 140
翻译中…
Problem Statement
翻译中…
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$.
翻译中…
样例
Input #1
3
2 5
Output #1
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.
Input #2
2
3
Output #2
6
Input #3
6
0 153 10 10 23
Output #3
53
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。