You have a bag of n positive integers (values may repeat). One move works like this: choose any value v still in the bag, earn v multiplied by the number of copies of v currently present, then remove every copy of v and every copy of v-1 and v+1 from the bag. Keep making moves until the bag is empty.
Return the maximum total points you can earn.
Input format
Line 1: an integer n, the number of values.
Line 2: n space-separated positive integers.
Output format
A single integer: the maximum total points.
Constraints
- 1 <= n <= 100000
- 1 <= each value <= 10000