406747: GYM102535 D Clingy Mo

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Clingy Motime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

It's a new year, and there are still firecrackers every now and then. With those loud sounds as cover, you decided to use this time to test your new spy equipment!

Even spies have New Year's Resolutions. In the past year, you've spent a decent amount of your downtime playing Bomberman. Well, this year you've decided to increase your skill in handling actual explosives—not for games, but for professional use only!

And so we look at the explosives that you have, which you got from the Armory of Clingy Molotovs.

You have $$$n$$$ explosives, and you arrange them in a line. As they are clingy, they have to be with their fellow molotovs in order to detonate. Specifically, a clingy molotov will detonate and explode if and only if there is at least one clingy molotov to its left, and at least one clingy molotov to its right.

Each molotov has an Explosion Rating $$$E_i$$$, which is proportional to the amount of damage that it can cause. Now, what is the total Explosion Rating of all the clingy molotovs that will explode?

Input

The input starts with a line containing an integer $$$n$$$, the number of explosives. The second line contains $$$n$$$ integers, $$$E_1, E_2, \ldots, E_n$$$, denoting the explosion rating of each of the clingy molotoves from left to right.

Constraints

$$$1 \leq n \leq 100$$$

$$$0 \leq E_i \leq 1000$$$

Output

Output, in a single line, a single integer denoting the total Explosion Rating of all the clingy molotovs that will explode.

ExamplesInput
6
1 3 5 2 3 10
Output
13
Input
2
5 10
Output
0

加入题单

上一题 下一题 算法标签: