N = gets.to_i
B = gets.split.map(&:to_i)

R = Array.new(N)

B.each_with_index do |b, idx|
  if idx == 0
    R[0] = b
    R[1] = b
  else
    if R[idx] > b
      R[idx] = b
    end

    R[idx + 1] = b
  end
end

p R.inject(:+)
