n = gets.to_i
bs = gets.split.map(&:to_i)

sum = bs.min
(n-1).times do |i|
  b = bs[i]
  b_after_max = bs[i+1..-1].min
  next unless b_after_max
  sum +=  [b, b_after_max].min
end

puts sum + bs.last
