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())

c = [[]]*2
c[0] = list(map(int, input().split()))
c[1] = list(map(int, input().split()))

pred = [ ([0] * n) for _ in range(2)]
suff = [ ([0] * n) for _ in range(2)]
summ = [ ([0] * n) for _ in range(2)]

# pred[0][0] = c[0][0]
# pred[1][0] = c[1][0]

# suff[0][0] = c[0][~0]
# suff[1][0] = c[1][~0]

summ[0][0] = c[0][0]
summ[1][0] = c[1][0]

j = 0
for j in range(2):
	for i in range(1, n):
		pred[j][i] = pred[j][i-1] + i * c[j][i]
		suff[j][i] = suff[j][i-1] + i * c[j][~i]
		summ[j][i] = summ[j][i-1] + c[j][i]
# print('pred = ' + str(pred))
# print('suff = ' + str(suff))
# print('summ = ' + str(summ))

ans = [0] * n
curr_zig_zag = 0

for i in range(0, n):
	if i % 2 == 0:
		if i == 0:
			ans[i] = pred[0][-1] + suff[1][-1] + summ[1][-1] * n
			# print('ans[0] = ' + str(ans[0]))
		else:
			curr_zig_zag += c[1][i-1] * (2*i-2) + c[0][i-1] * (2*i-1)
			# print('curr_zig_zag = ' + str(curr_zig_zag))

			ans[i] = (pred[0][-1] - pred[0][i-1]) + (summ[0][-1] - summ[0][i-1]) * (2*i - 2)
			# print('added: ' + str((pred[0][-1] - pred[0][i-1]) + (summ[0][-1] - summ[0][i-1]) * (2*i - 1)))

			ans[i] += (suff[1][n-i-1]) + (summ[1][-1] - summ[1][i-1]) * (n + 2*i - 2)
			# print('added: ' + str((suff[1][n-i-1]) + (summ[1][-1] - summ[1][i-1]) * (n + 2*i - 2)))

			ans[i] += curr_zig_zag
			# print('ans[' + str(i) + '] = ' + str(ans[0]))

	else:
		curr_zig_zag += c[0][i-1] * (2*i-2) + c[1][i-1] * (2*i-1)
		ans[i] = (pred[1][-1] - pred[1][i-1]) + (summ[1][-1] - summ[1][i-1]) * (2*(i-1) + 1)
		ans[i] +=  (suff[0][n-i-1]) + (summ[0][-1] - summ[0][i-1]) * (n + 2*(i-1) + 1)
		ans[i] += curr_zig_zag

print(max(ans))


# all_way = pred[0][-1] + suff[1][-1] + summ[1][-1] * n
# print(all_way)

# print(pred)
# print(suff)
# print(summ)