A pottery kiln runs one firing job per unit-length time slot (slots numbered 1, 2, 3, ...). There are n jobs. Job i takes exactly one slot, must be placed in a slot no later than its deadline d[i] ≥ 1, and pays a bounty p[i] > 0 if it is run. You may run any subset of jobs, at most one per slot, and each chosen job must occupy some slot t ≤ d[i].
Maximize the total bounty of the jobs you run.
Input format
Line 1: an integer n.
Next n lines: two integers d and p — the deadline and the bounty of one job.
Output format
A single integer: the maximum total bounty attainable.
Constraints
- 1 ≤ n ≤ 100000
- 1 ≤ d[i] ≤ 100000
- 1 ≤ p[i] ≤ 1000000000