Well, this is quite a powerful task
Everyone knows that Kostya is a fan of everything powerful.
This time, he got his hands on two arrays and of length . He came up with his special powerful characteristic. The power of two arrays of the same length is defined as the number of indices for which a_i = b_i.
However, simply counting the power, in his opinion, is not powerful enough. Therefore, he invented three powerful operations:
Replace a_{i-1} with a_i - 1 for any (2 \leq i \leq |a|). He can apply this operation any number of times.
Replace b_{i-1} with b_i - 1 for any (2 \leq i \leq |a|). He can apply this operation any number of times.
Choose an index (1 \leq i \leq n) and remove a_i and b_i, thereby reducing the length of both arrays by one. He can apply this operation no more than once, and only if the operations of the second and first types have not yet been applied.
Help Kostya find the maximum possible power of the arrays and after applying his powerful operations.
The first line contains a single integer (1 \leq n \leq 2 \cdot 10^5) — the length of the arrays and .
The second line contains the array of length (1 \leq a_i \leq 10^6).
The third line contains the array of length (1 \leq b_i \leq 10^6).
Output a single number — the power of the arrays and .
Example 1
Example 2
In the first example:
We have the array a = \{12, 17, 7, 8, 9\} and b = \{7, 9, 2, 1, 8\}.
We apply the third operation for i = 4.
Then a = \{12, 17, 7, 9\} and b = \{7, 9, 2, 8\}.
We apply the first operation for i = 3.
Then a = \{12, 6, 7, 9\} and b = \{7, 9, 2, 8\}.
We apply the first operation for i = 2.
Then a = \{5, 6, 7, 9\} and b = \{7, 9, 2, 8\}.
We apply the second operation for i = 4.
Then a = \{5, 6, 7, 9\} and b = \{7, 9, 7, 8\}.
We apply the second operation for i = 3.
Then a = \{5, 6, 7, 9\} and b = \{7, 6, 7, 8\}.
We apply the second operation for i = 2.
Then a = \{5, 6, 7, 9\} and b = \{5, 6, 7, 8\}.
Then the power of the arrays and is equal to since for i = \{2, 3, 4\} it holds that a_i = b_i.
Subtask ( points): n \leq 10
Subtask ( points): n \leq 100
Subtask ( points): n \leq 5 \cdot 10^3
Subtask ( points): a_i \leq 100
Subtask ( points): and are permutations
Subtask ( points): Without additional constraints