fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val B = readLine()!!.split(" ").map(String::toInt)
    val ans = B[0] + B.last() + B.windowed(2) { it.min()!! }.sum()
    println(ans)
}

fun <T, R> List<T>.windowed(size: Int, transform: (List<T>) -> R): List<R> {
    return (0..this.size - size).map { i ->
        transform(this.slice(i until i + size))
    }
}