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 A {

	static int[][] a = null, used = null;
	static int n = 0;

	public static void main(String[] args) {

		try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {

			//String[] line = reader.readLine().split(" ");
			//int n = Integer.parseInt(line[0]);
			n = Integer.parseInt(reader.readLine());

			int way1 = 0, way2 = 0, max = 0;

			a = new int[n][2];
			used = new int[n][2];
			String[] line = reader.readLine().split(" "),
			line2 = reader.readLine().split(" ");
			for(int i = 0; i < n; i++) {
				a[i][0] = Integer.parseInt(line[i]);
				a[i][1] = Integer.parseInt(line2[i]);
			}

			//Way 1
			for(int i = 2; i <= 2 * n; i++) {
				if(i <= n) {
					way1 += a[i - 1][0] * (i - 1);
				} else {
					way1 += a[2 * n - i][1] * (i - 1);
				}
			}
			//Way 2
			for(int i = 2; i <= 2 * n; i++) {
				if(i <= n + 1) {
					way2 += a[i - 2][1] * (i - 1);
				} else {
					way2 += a[2 * n - i + 1][0] * (i - 1);
				}
			}

			max = Math.max(way2, way1);

			int curX = 0, curY = 0, curSum = 0;
			for(int i = 0; i + 1 < 2 * n; i++) {
				used[curX][curY] = 1;

				Pair next = next(curX, curY);
				curSum += a[next.x][next.y] * (i + 1);

				int koef = (next.y == 0 ? next.x : 2 * n - next.x - 1);
				int way = way1 -= a[next.x][next.y] * (next.y == 0 ? next.x : 2 * n - next.x - 1);
				max = Math.max(max, way + curSum);

				koef = (next.y == 1 ? next.x + 1 : 2 * n - next.x);
				way = way2 -= a[next.x][next.y] * (next.y == 1 ? next.x + 1 : 2 * n - next.x);
				max = Math.max(max, way + curSum);

				curX = next.x;
				curY = next.y;
			}

			System.out.println(max);

		} catch(IOException e) {
		}
	}

	static Pair next(int xPos, int yPos) {
		if(yPos == 0) {
			if(used[xPos][1] == 0) return new Pair(xPos, 1);
			else return new Pair(xPos < n - 1 && used[xPos + 1][0] == 0 ? xPos + 1 : xPos - 1, 0);
		} else {
			if(used[xPos][0] == 0) return new Pair(xPos, 0);
			else return new Pair(xPos < n - 1 && used[xPos + 1][1] == 0 ? xPos + 1 : xPos - 1, 1);
		}
	}

	static class Pair {
		int x, y;
		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

}