let n=Int(readLine()!)!
let b=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var a : [Int] = []

a.append(b[0])

var i = 0

for i in 1..<n - 1 {
  a.append( min( b[i-1], b[i] ) )
}

a.append(b[n-2])
print( a )
print( a.reduce(0, combine: + ) )

