P14978 [HackerEarth] Some-one(as if, you care about the name) is tired of getting bored. You decided to play a new game. Yes, it is a single-player game. Insert forever alone meme.
普及
题目描述

Some-one(as if, you care about the name) is tired of getting bored. You decided to play a new game. Yes, it is a single-player game. Insert forever alone meme.

You have 'n' integers. You can make several eliminations. In a single elimination, you can choose an element of the sequence (ak) and delete it and for doing that he gains ak points. However, to eliminate ak, he has to remove all elements equal to ak+1 and ak-1 from the sequence. So play at your own risk.

You will win anyway. What you really want is to get the maximum points in the game. Atleast we think that is what you want.

Input
The first line contains integer n (1 ≤ n ≤ 100) that shows how many numbers are in the sequence.

The second line contains n integers a1, a2, ..., an (1i ≤ a ≤ 100).

Output
Print a single integer — the maximum number of points that Alex can earn.

Sample Input-1
2

1 2

Sample Output-2
2

Sample Input-2
3

1 2 3

Sample Output-2
4

Sample Input-3
9

1 2 1 3 2 2 2 2 3

Sample Output-3
10

Explanation
In the third test case, at first step we need to choose any element equal to 2. Then our sequence is [2,2,2,2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.

SAMPLE INPUT
2
1 2

SAMPLE OUTPUT
2

输入格式

见题面

输出格式

见题面

样例输入
100 6 1 5 7 10 10 2 7 3 7 2 10 7 6 3 5 5 5 3 7 2 4 2 7 7 4 2 8 2 10 4 7 9 1 1 7 9 7 1 10 10 9 5 6 10 1 7 5 8 1 1 5 3 10 2 4 3 5 2 7 4 9 5 10 1 3 7 6 6 9 3 6 6 10 1 10 6 1 10 3 4 1 7 9 2 7 8 9 3 3 2 4 6 6 1 2 9 4 1 2
样例输出
14