No Thanks!
Time limit0.5sMemory limit1024 MB
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 to . Players win number cards in auctions. At the end, each player scores the cards they hold as follows.
- Sort the integers in ascending order, then split them into groups of consecutive runs where each neighboring pair differs by .
- For each group, take its smallest number. The score is the sum of these smallest numbers.
For example, if the cards are , , , , , , , , , , they form the groups , , , and . The score is .
Write a program that computes the score from the cards a player holds.
Input
The first line contains , the number of cards.
The second line contains the integers written on the cards, separated by spaces, in ascending order.
Output
Print the score computed by the rules above on the first line.
Constraints
- For all ,
- For all ,