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

n = int(input())

data_a = list(map(int,input().split()))
data_b = list(map(int,input().split()))

answer = 0

big_data = [ 0 for i in range(2 * n)]

for i in range(2*n):
    if i < n :
        big_data[i] = data_a[i]
    else:
        big_data[i] = data_b[n - 1 - (i - n ) ]

prefix_sums = [0 for i in range(2*n +1)]

for i in range(1, 2 *n  +1):
    prefix_sums[i ] = prefix_sums[i - 1] + big_data[i - 1]

ss = [0 for i in range(2 * n )]

for i in range(1, 2 *n):
    ss[i] = ss[i - 1] + i * big_data[i]
    
curr = 0


def get_sum_1(i):
    i+=1
    ret = ss[2 * n - 1- i] - ss[i]
    ret -= i *(prefix_sums[2*n -1- i ] - prefix_sums[i])
    return ret



prefix_sums_back = [0 for i in range(2*n +1)]

for i in range(1, 2 *n  +1):
    prefix_sums_back[i] = prefix_sums[i - 1] + big_data[2 * n -  i]

ss_back = [0 for i in range(2 * n )]

for i in range(1, 2 *n):
    ss_back[i] = ss_back[i - 1] + i * big_data[2*n - i]
    


def get_sum_2(i):
    i+=1
    ret = ss_back[2 * n - 1 - i] - ss_back[i]
    ret*= -1
    ret += i *(prefix_sums_back[2*n- 1 - i ] - prefix_sums_back[i])
    return ret

up = True

answer = get_sum_1(-1)
for i in range(n):
    
    if up:
        curr+= 2 * i * data_a[i]
        curr += (2*i + 1)*data_b[i]
        answer = max(answer, curr + get_sum_2(i))
        up = False
    else:
        curr += 2 * i * data_b[i]
        curr += (2*i + 1)*data_a[i]
        answer = max(answer, curr + get_sum_1(i) )
        up = True



answer = max(answer, curr)
print(answer)
