a = gets.to_i

b = gets.chomp.split.map(&:to_i)

i = 1
sum = b[0]


if b.length == 1
	sum += b[0]
elsif b.length == 2
	if b[0] <= b[1]
		sum += b[0]+b[1]
	elsif b[0] > b[1]
		sum = b[1]*3
	end
else

	while i < b.length-1
		if b[i-1] <= b[i] && b[i] <= b[i+1]
			sum += b[i]
		else
			sum += [b[i-1], b[i]].min
		end
		i += 1
	end

	if b[-3] <= b[-2] && b[-2] <= b[-1]
		sum += b[-2]+b[-1]
	else
		sum += b[-3]+b[-1]
	end
end

puts sum