input = require("fs").readFileSync("/dev/stdin", "utf8")

lines = input.split("\n")
N = lines.shift() * 1
B = lines.shift().split(' ').map(function(i) { return i * 1 })

ans = 0
max = B[N - 2]
for (i = N - 2; i >= 0; i--) {
    if (max > B[i]) {
        max = B[i]
    }
    ans += max
}
ans += max

console.log(ans)
