시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB135967867.241%

문제

In the card game “No Thanks,” the deck of cards consists of $36$ cards numbered $1$–$36$, 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 $36$ cards.

입력

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

출력

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

예제 입력 1

5
1 7 5 3 4

예제 출력 1

11

예제 입력 2

6
2 1 3 8 4 5

예제 출력 2

9