Ограничения: время – 250ms/500ms, память – 256MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)
Cleon rolls a regular six faced dice `N` times.
He starts with an initial score of 0.
Let the number rolled by him in a particular round be `X`.
If Cleon rolls the number `X` `k` times in a row, he will add `k*X` to his score.
For example, if Cleon rolls 1,2,2,2,5,2, he gets `1+2+2*2+3*2+5+2=20` points.
Calculate the Cleon's score after `N` rounds.
The first line of input contains of a single integer
`N` (`1<=N<=1000`) -- the number of rounds. The second line contains `N` space-separated integers
`D_i` (`1 <= D_i <= 6`) -- the number rolled in `i`th round.
Output the Cleon's score.
```sample Sample Input
6
1 2 2 2 5 2
```
```sample Sample Output
20
```