0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 21:34:59 +00:00
OI-codes/Luogu/P4445/P4445.cpp

18 lines
298 B
C++
Raw Normal View History

2021-11-19 09:01:13 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[100005];
2021-11-19 09:01:13 +00:00
long long ans = 0;
cin >> n;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
cin >> a[i];
}
2021-11-19 09:01:13 +00:00
for (int i = 1; i < n; i++) {
ans += max(a[i], a[i - 1]);
}
cout << ans << endl;
return 0;
}