# frozen_string_literal: true

n = gets.to_i
b = gets.split.map(&:to_i)
a = Array.new(n) { 1000000 }

0.upto(n - 2) do |i|
  a[i] = [a[i], b[i]].min
  a[i + 1] = [a[i], b[i]].max
end

puts a.reduce(:+)
