#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Rar the Cat is shopping for cat food to prepare for the Great Feline Feast.

There are *N* boxes of cat food in the supermarket, numbered from 1 to *N*. The *i*th box of cat food costs $ *A _{i}*.

Being a *greedy* cat, Rar the Cat wants to get all the cat food.

As the supermarket is having a sale today, there are *N* vouchers available, also numbered 1 to *N*. By buying the *i*th box of cat food, Rar the Cat will receive the i*th* voucher. Rar the Cat can exchange the *i*th voucher for at most *B _{i}* boxes of cat food at no cost.

What is the minimum amount of money Rar the Cat needs to pay to get all the cat food?

## Limits

For all testcases, 1 ≤ *N* ≤ 5000, 0 ≤ *A _{i}* ≤ 10

^{9}, 0 ≤

*B*≤ 5000 in addition to the limits below.

_{i}Subtask 1 (23%): *B _{i}* = 1.

Subtask 2 (77%): No further constraints.

Subtask 3 (0%): Sample Testcases.

## Input

The first line of input will contain one integer, *N*.

The following line will contain *N* integers, *A _{i}*.

The following line will contain *N* integers, *B _{i}*.

## Output

A single integer, the minimum amount of money Rar the Cat needs to pay to get all the cat food.

## Sample Testcase 1

**This testcase is valid for subtasks 1, 2, 3.**

### Input

5 1 2 3 4 5 1 1 1 1 1

### Output

6

### Explanation

You can buy the first three boxes of cat food and exchange the two vouchers obtained for the last two boxes of cat food.

## Sample Testcase 2

**This testcase is valid for subtasks 2, 3.**

### Input

5 1 10 3 15 8 2 3 3 2 2

### Output

4

### Explanation

You can buy the first and third boxes of cat food.

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 23 | 32 | 0.5s | 16MB | Minimum |

2 | 77 | 65 | 0.5s | 16MB | Minimum |

3 | 0 | 2 | 0.5s | 16MB | Minimum |

### Judge Compile Command

g++-8 ans.cpp -o vouchers -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512