Chef Jami had recently started home delivery service for pizzas. Jami has only a single delivery boy that delivers the order by riding his bicycle. Today Chef Jami received pizza order, the house of the person that ordered the -th pizza needs unit time to prepare and the order is km away from the restaurant. The delivery boy cannot deliver more than one order at a time and takes 1 unit time per km. Therefore, after delivering an order, he must return back to the restaurant to take the next order. It takes the delivery man no time to get back to the restaurant and the Chef can continue cooking without waiting for the delivery man to come for the next order.
The delivery boy is a lazy person and does not want to spend much time in the delivery process, so he wants your help in prioritizing the orders so that he can deliver all orders in least amount of time.
First line contain the number of orders ().
Second line contains space separated integers () - the packing time of every pizza by Chef Jami and the third line contains space separated integers () - the distance of the house from the restaurant.
Print the least amount of time to deliver all the orders.
Input | Output |
---|---|
4 1 1 30 5 5 30 5 10 | 51 |
Input | Output |
---|---|
6 11 9 16 19 15 17 11 23 9 7 11 6 | 93 |