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

# 1234
# -------|
# -------|
# 8765
# |------|
# ||-----|
# 1876
# 2345
#
# 1456
# 2387
#
#
# 123456
# cba987
#
# 145678
# 23cba9
#
# 14589a
# 2367cb

# 1cba98
# 234567
#
# 145cba
# 236789
#
# 14589c
# 2367ab

n = int(raw_input())
first = raw_input().split()
second = raw_input().split()
fn = [int(x) for x in first]
sn = [int(x) for x in second]
ssn = [0] * n
ssn[-1] = fn[-1] + sn[-1]
for i in reversed(range(n-1)):
    ssn[i] = (sn[i] + fn[i] + ssn[i+1])
ret = 0
for i in xrange(n):
    ret += i * fn[i] + (2 * n - i - 1) * sn[i]

# print ret

tmp1 = ret
for i in xrange(2, n):
    tmp2 = tmp1 + ssn[i] * 2 + 2 * fn[i-1]
    tmp2 = tmp2 - (2 * n - 1) * sn[i - 2] - (2 * n - 2) * sn[i - 1]
    tmp2 = tmp2 + (2 * i - 2) * sn[i - 2] + (2 * i - 1) * sn[i - 1]
    ret = max(ret, tmp2)
    # print tmp2
    tmp1 = tmp2
# print '******'
ret2 = fn[0] + sn[0]
for i in xrange(1, n):
    ret2 += (i + 1) * sn[i] + (2 * n - i) * fn[i]
# print ret2
tmp1 = ret2
for i in xrange(3, n):
    tmp2 = tmp1 + ssn[i] * 2 + 2 * sn[i-1]
    tmp2 = tmp2 - (2 * n - 1) * fn[i - 2] - (2 * n - 2) * fn[i - 1]
    tmp2 = tmp2 + (2 * i - 2) * fn[i - 2] + (2 * i - 1) * fn[i - 1]
    ret2 = max(ret, tmp2)
    # print tmp2
    tmp1 = tmp2

print max(ret, ret2)
