+ Time limit: 2 seconds
+ Memory limit: 256 megabytes
----------
We have several individuals (psychopaths) in a row. Each individual has a power and a cost, both represented by a natural number. The power of any two individuals is different. In one operation, we can instruct an individual to kill one of their neighbors, chosen by us, provided that the power of the killer is greater than the victim. To carry out this instruction, we must pay an amount equal to the cost of the killer individual.
In this problem, the power and cost of $n$ individuals are given, and for every interval of them, you must calculate the minimum possible amount of money required until only one individual remains. Finally, output the sum of these values over all intervals, modulo $998244353$.
\**It is guaranteed that the powers of the individuals form a random permutation of 1 to $n$.**
# Input
In the first line, the number $n$ is given, representing the count of individuals.
In the second line, the array $a_1, a_2, \ldots, a_n$ is given, representing the powers of the individuals.
In the third line, the array $b_1, b_2, \ldots, b_n$ is given, representing the costs of the individuals.
# Constraints
$$ 1 \le n \le 10^6 $$
$$ 0 \le b_i \le 10^6 $$
$$ 1 \le a_i \le n $$
It is guaranteed that the array $a_1, a_2, \ldots, a_n$ is a random permutation of the numbers $1$ to $n$.
The problem consists of 36 tests. One test is the sample. $n=100$ holds in 2 tests. $n=10^5$ holds in 2 tests, and $n=10^6$ holds in 32 tests.
# Output
Calculate the minimum money that can be paid for each interval until only one individual remains, and output the sum of these values modulo $998244353$.
# Example
## Sample Input 1
```
10
5 9 3 4 1 7 6 8 10 2
54 92 52 56 26 75 64 12 23 94
```
## Sample Output 1
```
5905
```