
The organizers of the IDDA Cup are arranging T-shirts for the final round, with gift- presenters and boxes at their disposal. Each gift-presenter is currently holding a specific number of T-shirts in their hands, and each box has a predetermined capacity for holding T-shirts. The number of T-shirts in the -th gift-presenter's hands is a_i and the capacity of the -th box is b_i. Currently the boxes are empty and organizers want to distribute the T-shirts that the gift-presenters hold to the boxes so that they can rest a bit. However, they cannot exceed the capacity of any box.
For each gift-presenter numbered from to , the T-shirts that the -th of them holds can be placed in the -th and (i~mod~n + 1)-th box.
Find the maximum number of T-shirts that can be distributed into boxes, if organizers make the optimal distribution.
Contains zero or more test cases, and is terminated by end-of-file. For each test case:
The first line contains an integer n~(3 \le n \le 10^6).
The second line contains integers a_1, a_2, ..., a_n~(0 \le a_i \le 10^9).
The third line contains integers b_1, b_2, ..., b_n~(0 \le b_i \le 10^9).
It is guaranteed that the sum of all does not exceed 10^6.
For each test case, print in a new line the maximum number of T-Shirts that can be distributed into boxes.
Example 1
This task consists of the following subtasks. If all tests of a subtask are passed, you will earn points for that subtask.
( points): n \leq 10, a_i, b_i \leq 10;
( points): n \leq 10, a_i, b_i \leq 100;
( points): no additional constraints;