Given n tasks with their deadlines and the profit you’ll get by completing that task before the deadline, you’d like to know what the maximum total profit is you can get. Completing each task takes 1 day. If you don’t complete a task before the deadline, you don’t get anything.
You start from day 1. How much profit can you make?
Input
The first line of the input contains a single integer n (1 ≤ n ≤ ) the number of tasks.
The next n lines contain space-separated pairs of integers (1 ≤ , ≤ ) the deadline and the profit for completing each task.
Output
The program should print the maximum total profit you can have.
Examples
Input
Output
3
4 10
1 3
2 7
2 3
20
5
1 1
4 100
4 200
4 300
4 200
800
Explanation
10 + 3 + 7
First, perform the task with the deadline 1 ⇒ earn 3
Then perform the task with the deadline 2 ⇒ earn 7
Then perform the task with the deadline 4 ⇒ earn 10