No Thanks!

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

In the card game “No Thanks,” the deck of cards consists of 3636 cards numbered 113636, and players collect cards to their score pile as the game is played. A player’s final score is the sum of the numbers on their collected cards, with one exception: if a player has collected any cards with two or more consecutive numbers, only the smallest number of that group counts toward the score. Your job is to compute the score for a single player’s pile of cards, though here we allow play with a deck much larger than 3636 cards.

입력

The first line contains one integer, nn, representing the number of cards collected. The second line contains nn integers representing the numbers on the collected cards. You may assume that 1n900001 \le n \le 90 000, all card values are in the range 1900001 \dots 90 000 inclusive, and no card value is repeated.

출력

Output a single line containing the score for the given set of cards.