A - No Thanks!
题号:NC223986
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

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 ≤ n ≤ 90 000, all card values are in the range 1 . . . 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

输出

复制
11
示例2

输入

复制
6 
2 1 3 8 4 5

输出

复制
9