n=gets.to_i-1
bNs=gets.chomp.split.map(&:to_i)
aNs=[bNs[0]]
maxbNsIndex = bNs.length - 1
n.times do |index|
  bIndex = [index,maxbNsIndex].min
  value = bNs[bIndex]
  addbIndex = bIndex + 1
  if addbIndex > maxbNsIndex
    addbIndex = maxbNsIndex
  end
  aNs << [value, bNs[addbIndex]].min
end
puts aNs.inject(:+)