#K13736. Bonus Stars Calculation

    ID: 23979 Type: Default 1000ms 256MiB

Bonus Stars Calculation

Bonus Stars Calculation

You are given a sequence of integers representing the star value of items purchased by participants. The bonus stars are calculated based on consecutive groups of identical star values. Specifically, for each maximal contiguous group of identical stars of length \(L\) (with \(L > 1\)), the participant earns a bonus of \(L \times \text{star}\) for that group. If a group contains only one element (i.e. \(L = 1\)), then no bonus is awarded for that group.

For example, if the input sequence is [3, 3, 3, 1, 1, 2], there are three groups:

  • The group [3, 3, 3] yields a bonus of \(3 \times 3 = 9\).
  • The group [1, 1] yields a bonus of \(2 \times 1 = 2\).
  • The single element group [2] gives no bonus.

The total bonus stars would then be \(9 + 2 = 11\).

Your task is to compute the total bonus stars given the sequence of integers.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  1. The first line contains a single integer \(N\) representing the number of items.
  2. The second line contains \(N\) space-separated integers representing the star values of the items.

outputFormat

Output the total bonus stars calculated according to the rules described above via standard output (stdout).

## sample
1
5
0