fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) {
    val N = readInt()
    val B = readIntList()
    val A = Array(N) { 100000 }

    for (i in B.indices) {
        A[i] = B[i].coerceAtMost(A[i])
        A[i+1] = B[i].coerceAtMost(A[i+1])
    }

    println(A.sum())
}