6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

#!/usr/bin/python3

def solve(N, A, B):
    sumright = sum(A) + sum(B)
    fromtop = 0
    for i in range(N):
        fromtop += i * A[i]
    for i in range(N):
        fromtop += (N + i) * B[-1 - i]

    frombottom = 0
    for i in range(N):
        frombottom += i * B[i]
    for i in range(N):
        frombottom += (N + i) * A[-1 - i]

    best = fromtop

    cur = 0
    topbias = 0
    bottombias = 0

    # print(f'0: {best}')

    for i in range(1, N):
        fromtop -= (i - 1) * A[i - 1]
        fromtop -= (2 * N - 1 - (i - 1)) * B[i - 1]

        frombottom -= (i - 1) * B[i - 1]
        frombottom -= (2 * N - 1 - (i - 1)) * A[i - 1]

        sumright -= A[i - 1] + B[i - 1]

        if i % 2 == 0:
            cur += (2 * (i - 1)) * B[i - 1] + (2 * (i - 1) + 1) * A[i - 1]

            topbias += 2 * sumright
            if i > 2:
                topbias -= A[i - 2] + A[i - 1] + B[i - 2] + B[i - 1]

            best = max(best, cur + fromtop + topbias)
            # print(f'{i}: {cur + fromtop + topbias}, cur={cur}, fromtop={fromtop}, sumright={sumright}, topbias={topbias}')
        else:
            cur += (2 * (i - 1)) * A[i - 1] + (2 * (i - 1) + 1) * B[i - 1]

            if i == 1:
                bottombias += sumright
            else:
                bottombias += 2 * sumright
                bottombias -= A[i - 2] + A[i - 1] + B[i - 2] + B[i - 1]


            best = max(best, cur + frombottom + bottombias)
            # print(f'{i}: {cur + frombottom + bottombias}, cur={cur}, frombottom={frombottom}, sumright={sumright}, bottombias={bottombias}')

    return best


def main():
    N = int(input())
    A = [int(e) for e in input().split(' ')]
    B = [int(e) for e in input().split(' ')]
    assert len(A) == N
    assert len(B) == N
    print(solve(N, A, B))


if __name__ == '__main__':
    main()
