cho.sh
Notes
Loading...

Cyclic Shift Dot Product

Time limit

1s

Memory limit

512 MB

Problem

There are two sequences X and Y, each containing N numbers. One cyclic shift removes the last element of a sequence and inserts it at the front. For example, one cyclic shift changes {1, 2, 3} into {3, 1, 2}, and another shift changes it into {2, 3, 1}.

You may apply zero or more cyclic shifts to X, and independently zero or more cyclic shifts to Y. After all shifts, compute the score S as follows.

S = X[0] * Y[0] + X[1] * Y[1] + ... + X[N-1] * Y[N-1]

Find the maximum possible value of S.

Input

The first line contains the integer N.

The second line contains the N numbers in X. The third line contains the N numbers in Y.

N is a positive integer not greater than 60,000. Every number in X and Y is an integer from 0 to 99, inclusive.

Output

Print the maximum possible value of S.