- Time limit: 2.00 s
- Memory limit: 512 MB
Uolevi is participating in a programming contest. There are tasks that have to be solved in order of difficulty. Task takes minutes to solve and solving it minutes after the contest started yields points. If task is harder than task then . Uolevi can choose to skip some or all of the tasks. Skipping a task takes no time. What is the maximum number of points Uolevi can achieve?
Input
The first line contains a single integer . The second line contains integers . The third line contains integers .
Output
Print the maximum score Uolevi can get.
Constraints
- if
Example 1
Input:
5 1 2 3 4 5 10 19 19 12 14
Output:
41
Example 2
Input:
10 3 5 8 9 11 13 16 17 18 20 1 16 19 10 14 11 32 8 18 19
Output:
22