problem-4-1
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

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