Under construction

Still being built. Things may change

No Thanks!

Time limit0.5sMemory limit1024 MB

Summary
Given N sorted card numbers, sum the smallest value of each run of consecutive integers.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

No Thanks! is a board game played with number cards from 33 to 3535. Players win number cards in auctions. At the end, each player scores the cards they hold as follows.

  1. Sort the integers in ascending order, then split them into groups of consecutive runs where each neighboring pair differs by 11.
  2. For each group, take its smallest number. The score is the sum of these smallest numbers.

For example, if the cards are 66, 77, 1010, 1212, 1313, 1414, 1515, 2020, 2121, 2222, they form the 44 groups \[6,7]\[6, 7], \[10]\[10], \[12,13,14,15]\[12, 13, 14, 15], and \[20,21,22]\[20, 21, 22]. The score is 6+10+12+20=486 + 10 + 12 + 20 = 48.

Write a program that computes the score from the cards a player holds.

Input

The first line contains NN, the number of cards.

The second line contains the NN integers xix_i written on the cards, separated by spaces, in ascending order.

Output

Print the score computed by the rules above on the first line.

Constraints

  • 1≤N≤331 \le N \le 33
  • For all 1≤i≤N1 \le i \le N, 3≤xi≤353 \le x_i \le 35
  • For all 1≤i≤N−11 \le i \le N-1, xi<xi+1x_i < x_{i+1}

Examples1

  1. Example 1

    Input
    10
    6 7 10 12 13 14 15 20 21 22
    
    Expected output
    48