fun main(args: Array<String>) {
    val length = readLine()!!.toInt()
    val listB = readLine()!!.split(" ").map { it.toInt() }

    print(abc140c(length, listB))
}

fun abc140c(length: Int, listB: List<Int>): Int {

    val listA = mutableListOf(listB[0])

    when {
        length >= 3 -> {
            for (i in 1 until length - 1) {
                listA.add(listB[i].coerceAtMost(listB[i - 1]))
            }
            listA.add(listB[length - 2].coerceAtLeast(listB.last()))
        }
        else -> listA.add(listB.last())
    }

    return listA.sum()
}