lines = readlines.map{|line| line.split(' ').map(&:to_i)}
a=[]
a.push(lines[1][0])
for i in 0..lines[0][0]-1
  if lines[1][i-1]==nil then
    a.push([lines[1][i-1],lines[1][i]].min)
  else
    b=[lines[1][i-1],lines[1][i]]
    b.delete(nil)
    a.push(b.min)
  end
end
puts a.inject(:+)