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())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a[0] = 0
total_sum = sum(a) + sum(b)
remain_sum = total_sum

snake_weight = 0
curl_len = 2 * n - 1
curl_ud_weight = 0
curl_du_weight = 0

for i in range(1, n):
    curl_ud_weight += i * a[i]
    curl_du_weight += (i + 1) * b[i]
for i in range(n, 2 * n):
    curl_ud_weight += i * b[-(i - n) - 1]
    curl_du_weight += (i + 1) * a[-(i - n) - 1]


max_weight = curl_ud_weight
curl_weight = curl_ud_weight

snake_opt = -1
curl_opt = -1

for snake_len in range(2 * n):
    curl_len = 2 * n - 1 - snake_len
    remain = snake_len % 4
    if remain == 0 or remain == 3:
        #total_sum -= a[snake_len // 2]
        #print(a[snake_len // 2])
        snake_weight += snake_len * a[snake_len // 2]
        curl_ud_weight -= (snake_len // 2) * a[snake_len // 2]
        curl_du_weight -= (2 * n - snake_len // 2) * a[snake_len // 2]
        curl_weight = curl_ud_weight
    elif remain == 1 or remain == 2:
        #total_sum -= b[snake_len // 2]
        #print(b[snake_len // 2])
        snake_weight += snake_len * b[snake_len // 2]
        curl_du_weight -= (snake_len // 2 + 1) * b[snake_len // 2]
        curl_ud_weight -= (2 * n - 1 - snake_len // 2) * b[snake_len // 2]
        curl_weight = curl_du_weight

    curl_weight = max(curl_weight, 0)
    weight = snake_weight + curl_weight
    #print(snake_weight + curl_du_weight)
    #print(snake_weight + curl_ud_weight)
    #print("-")

    if weight > max_weight:
        max_weight = weight
    snake_opt = snake_len
    curl_opt = curl_len

print(max_weight)
#print("snake" , snake_opt)
#print("curl", curl_opt)

"""
3
0 1 0
0 0 0
"""