Question
Freelancer Deadline Earnings

A freelancer has N one-day tasks available. Each task has a deadline day and a payment. Only one task can be completed per day. A task earns payment only if it is completed on or before its deadline.

Find the maximum total payment the freelancer can earn.

Input

The first line contains an integer KaTeX can only parse string typed expression.

Each of the next KaTeX can only parse string typed expression lines contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the deadline and payment of a task.

Output

Print a single integer — the maximum total payment.

Example
Example 1:
Input
5

2 100
1 19
2 27
1 25
3 15
Output
142


Example 2:
Input
4

1 10
1 20
1 30
1 40
Output
40

Online