I. Integer Reaction
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

There is a sequence of $$$n$$$ integers, numbered from $$$1$$$ to $$$n$$$ from left to right. These integers come in two colors, $$$0$$$ and $$$1$$$, with each integer having exactly one color. These integers enter a multiset $$$S_1$$$ in the order of their numbering from $$$1$$$ to $$$n$$$.

Whenever a new integer $$$x$$$ enters $$$S_1$$$, you must choose an integer $$$y$$$ in $$$S_1$$$ whose color is different from $$$x$$$ to react with $$$x$$$, causing $$$x$$$ and $$$y$$$ to disappear and the reaction product $$$x+y$$$ to be inserted into another set $$$S_2$$$. If no such $$$y$$$ exists, no reaction occurs and only $$$x$$$ will be inserted into $$$S_1$$$.

Given the sequence of integers and the color of each integer, find the maximum possible value of the smallest element in $$$S_2$$$ after processing the last element.

Input

The first line contains an integer $$$n$$$ ($$$2\le n\le 10^5$$$), representing the number of integers.

The second line contains $$$n$$$ positive integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1\le a_i\le 10^8$$$), representing the sequence of integers.

The third line contains $$$n$$$ integers $$$c_1,c_2,\ldots,c_n$$$ ($$$c_i\in \{0,1\}$$$), where $$$c_i$$$ represents the color of the $$$i$$$-th integer.

It is guaranteed that there is at least one $$$i$$$ such that $$$c_i=0$$$, and at least one $$$j$$$ such that $$$c_j=1$$$.

Output

Output a single integer, representing the answer.

Examples
Input
4
1 3 2 4
0 0 1 1
Output
5
Input
6
1 3 4 2 5 6
0 1 0 1 0 1
Output
4
Input
7
3 3 4 4 5 3 1
0 0 1 1 1 0 0
Output
7