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

import java.io.*;
import java.util.*;

public class CF1016C {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		long[] aa = new long[n];
		for (int i = 0; i < n; i++)
			aa[i] = Long.parseLong(st.nextToken());
		st = new StringTokenizer(br.readLine());
		long[] bb = new long[n];
		for (int i = 0; i < n; i++)
			bb[i] = Long.parseLong(st.nextToken());
		long[] dp = new long[1 + n];
		for (int i = 0; i < n; i++)
			if (i % 2 == 0)
				dp[i + 1] = dp[i] + i * 2 * aa[i] + (i * 2 + 1) * bb[i];
			else
				dp[i + 1] = dp[i] + i * 2 * bb[i] + (i * 2 + 1) * aa[i];
		long[] qq = new long[1 + n];
		for (int i = n - 1; i >= 0; i--)
			qq[i] += aa[i] + bb[i] + qq[i + 1];
		long qa = 0, qb = 0;
		long[] dq = new long[1 + n];
		for (int i = n - 1; i >= 0; i--) {
			long m = (n - 1 - i) * 2 + 1;
			qa += qq[i + 1] + m * bb[i];
			qb += qq[i + 1] + m * aa[i];
			dq[i] = i % 2 == 0 ? qa : qb;
		}
		long ans = 0;
		for (int i = 0; i <= n; i++) {
			long w = dp[i] + qq[i] * i * 2 + dq[i];
			ans = Math.max(ans, w);
		}
		System.out.println(ans);
	}
}
