import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author llamaoo7
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            int[] b = new int[n];
            for (int i = 0; i < n; i++) b[i] = in.nextInt();
            long[] col = new long[n + 10];
            for (int i = n - 1; i >= 0; i--) {
                col[i] = a[i] + b[i] + col[i + 1];
            }
            long[] cs = new long[n + 10];
            long[] csb = new long[n + 10];
            for (int i = n - 1; i >= 0; i--) {
                cs[i] = b[i] * (1 + 2 * (n - 1 - i)) + col[i + 1] + cs[i + 1];
                csb[i] = a[i] * (1 + 2 * (n - 1 - i)) + col[i + 1] + cs[i + 1];
            }
            long ret = 0;
            for (int i = 0; i < n; i += 2) {
                ret = Math.max(ret, cs[i]);
                int t = i * 2;
                ret = Math.max(ret, t * a[i] + (t + 1 * b[i]) + csb[i + 1]);
                ret = Math.max(ret, t * a[i] +
                        (t + 1) * b[i] +
                        (i < n - 1 ? (t + 2) * b[i + 1] + (t + 3) * a[i + 1] : 0) +
                        (t + 4) * col[i + 2]
                        + cs[i + 2]);
            }
            out.println(ret);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author llamaoo7
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            int[] b = new int[n];
            for (int i = 0; i < n; i++) b[i] = in.nextInt();
            long[] col = new long[n + 10];
            for (int i = n - 1; i >= 0; i--) {
                col[i] = a[i] + b[i] + col[i + 1];
            }
            long[] cs = new long[n + 10];
            long[] csb = new long[n + 10];
            for (int i = n - 1; i >= 0; i--) {
                cs[i] = b[i] * (1 + 2 * (n - 1 - i)) + col[i + 1] + cs[i + 1];
                csb[i] = b[i] * (1 + 2 * (n - 1 - i)) + col[i + 1] + cs[i + 1];
            }
            long ret = 0;
            for (int i = 0; i < n; i += 2) {
                ret = Math.max(ret, cs[i]);
                int t = i * 2;
                ret = Math.max(ret, t * a[i] + (t + 1 * b[i]) + csb[i + 1]);
                ret = Math.max(ret, t * a[i] +
                        (t + 1) * b[i] +
                        (i < n - 1 ? (t + 2) * b[i + 1] + (t + 3) * a[i + 1] : 0) +
                        (t + 4) * col[i + 2]
                        + cs[i + 2]);
            }
            out.println(ret);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author llamaoo7
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[][] g = new long[2][n + 10];
            long[] t = new long[n + 10];
            long[] ct = new long[n + 10];
            long[] cb = new long[n + 10];
            for (int i = 0; i < n; i++) g[0][i] = in.nextInt();
            for (int i = 0; i < n; i++) g[1][i] = in.nextInt();
            for (int i = n - 1; i >= 0; i--) t[i] = t[i + 1] + g[0][i] + g[1][i];
            for (int i = n - 1; i >= 0; i--) {
                ct[i] = ct[i + 1] + t[i + 1] + g[1][i] * ((n - i) * 2 - 1);
                cb[i] = cb[i + 1] + t[i + 1] + g[0][i] * ((n - i) * 2 - 1);
            }
            int curT = 0;
            long sum = 0;
            long ans = 0;
            for (int i = 0; i < n; i += 2) {
                ans = Math.max(ans, sum + ct[i] + t[i] * curT);
                sum += g[0][i] * curT + g[1][i] * (curT + 1);
                ans = Math.max(ans, sum + t[i + 1] * (curT + 2) + cb[i + 1]);
                sum += g[1][i + 1] * (curT + 2) + g[0][i + 1] * (curT + 3);
                ans = Math.max(ans, sum);
                curT += 4;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author llamaoo7
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[][] g = new long[2][n + 10];
            long[] t = new long[n + 10];
            long[] ct = new long[n + 10];
            long[] cb = new long[n + 10];
            for (int i = 0; i < n; i++) g[0][i] = in.nextInt();
            for (int i = 0; i < n; i++) g[1][i] = in.nextInt();
            for (int i = n - 1; i >= 0; i--) t[i] = t[i + 1] + g[0][i] + g[1][i];
            for (int i = n - 1; i >= 0; i--) {
                ct[i] = ct[i + 1] + t[i + 1] + g[1][i] * ((n - i) * 2 - 1);
                cb[i] = cb[i + 1] + t[i + 1] + g[0][i] * ((n - i) * 2 - 1);
            }
            int curT = 0;
            long sum = 0;
            long ans = 0;
            for (int i = 0; i < n; i += 2) {
                ans = Math.max(ans, sum + ct[i]);
                sum += g[1][i] * (curT + 1);
                ans = Math.max(ans, sum + t[i + 1] * (curT + 2) + cb[i + 1]);
                sum += g[1][i + 1] * (curT + 2);
                sum += g[0][i + 1] * (curT + 3);
                ans = Math.max(ans, sum);
                sum += g[0][i + 2] * (curT + 4);
                curT += 4;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author llamaoo7
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[][] g = new long[2][n + 10];
            long[] t = new long[n + 10];
            long[] ct = new long[n + 10];
            long[] cb = new long[n + 10];
            for (int i = 0; i < n; i++) g[0][i] = in.nextInt();
            for (int i = 0; i < n; i++) g[1][i] = in.nextInt();
            for (int i = n - 1; i >= 0; i--) t[i] = t[i + 1] + g[0][i] + g[1][i];
            for (int i = n - 1; i >= 0; i--) {
                ct[i] = ct[i + 1] + t[i + 1] + g[1][i] * ((n - i) * 2 - 1);
                cb[i] = cb[i + 1] + t[i + 1] + g[0][i] * ((n - i) * 2 - 1);
            }
            int curT = 0;
            long sum = 0;
            long ans = 0;
            for (int i = 0; i < n; i += 2) {
                ans = Math.max(ans, sum + ct[i]);
                sum += g[1][i] * (curT + 1);
                ans = Math.max(ans, sum + t[i + 1] * (curT + 1) + cb[i + 1]);
                sum += g[1][i + 1] * (curT + 2);
                sum += g[0][i + 1] * (curT + 3);
                ans = Math.max(ans, sum);
                sum += g[0][i + 2] * (curT + 4);
                curT += 4;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.Scanner;

public class Main {

	private static long[] a = new long[300010];
	private static long[] b = new long[300010];

	private static long[] sum1 = new long[300010];
	private static long[] sum2 = new long[300010];
	private static long[] sum = new long[300010];

	private static boolean[][] vis = new boolean[3][300010];

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			a[i] = scan.nextLong();
		}
		for (i = 0;i < n;i ++) {
			b[i] = scan.nextLong();
		}

		for (i = n - 1;i >= 0;i --) {
			if (i == n - 1) {
				sum[i] = a[i] + b[i];
			} else {
				sum[i] = sum[i + 1] + a[i] + b[i];
			}
		}

		// sum1, bottom to up
		for (i = n - 1;i >= 0;i --) {
			long total = (n - i) * 2;
			if (i == n - 1) {
				sum1[i] = 0 * b[i] + 1 * a[i];
			} else {
				sum1[i] = 0 * b[i] + sum1[i + 1] + sum[i + 1] + (total - 1) * a[i];
			}
		}

		// sum2, up to bottom
		for (i = n - 1;i >= 0;i --) {
			long total = (n - i) * 2;
			if (i == n - 1) {
				sum2[i] = 0 * a[i] + 1 * b[i];
			} else {
				sum2[i] = 0 * a[i] + sum2[i + 1] + sum[i + 1] + (total - 1) * b[i];
			}
		}

		long ans = 0 , s = 0;
		int x = 0 , y = 0;
		for (i = 0;i < 2 * n;i ++) {
			vis[x][y] = true;
			// total
			if (x == 0) {
				if (vis[x + 1][y]) {
					s += (long) a[y] * i;
					y ++;
				} else {
					long temp = s + sum2[y] + (long) i * sum[y];
					if (temp > ans) {
						ans = temp;
					}
					s += (long) a[y] * i;
					x ++;
				}
			} else {
				if (vis[x - 1][y]) {
					s += (long) b[y] * i;
					y ++;
				} else {
					long temp = s + sum1[y] + (long) i * sum[y];
					if (temp > ans) {
						ans = temp;
					}
					s += (long) b[y] * i;
					x --;
				}
			}
		}
		if (s > ans) {
			ans = s;
		}
		System.out.println(ans);

	}

}


import java.util.Scanner;

public class Main {

	private static long[] a = new long[300010];
	private static long[] b = new long[300010];

	private static long[] sum1 = new long[300010];
	private static long[] sum2 = new long[300010];
	private static long[] sum = new long[300010];

	private static boolean[][] vis = new boolean[300010][3];

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , j , n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			a[i] = scan.nextLong();
		}
		for (i = 0;i < n;i ++) {
			b[i] = scan.nextLong();
		}

		for (i = n - 1;i >= 0;i --) {
			if (i == n - 1) {
				sum[i] = a[i] + b[i];
			} else {
				sum[i] = sum[i + 1] + a[i] + b[i];
			}
		}

		// sum1, bottom to up
		for (i = n - 1;i >= 0;i --) {
			long total = (n - i) * 2;
			if (i == n - 1) {
				sum1[i] = 0 * b[i] + 1 * a[i];
			} else {
				sum1[i] = 0 * b[i] + sum1[i + 1] + sum[i + 1] + (total - 1) * a[i];
			}
		}

		// sum2, up to bottom
		for (i = n - 1;i >= 0;i --) {
			long total = (n - i) * 2;
			if (i == n - 1) {
				sum2[i] = 0 * a[i] + 1 * b[i];
			} else {
				sum2[i] = 0 * a[i] + sum2[i + 1] + sum[i + 1] + (total - 1) * b[i];
			}
		}

		long ans = 0 , s = 0;
		int x = 0 , y = 0;
		for (i = 0;i < 2 * n;i ++) {
			vis[x][y] = true;
			// total
			if (x == 0) {
				if (vis[x + 1][y]) {
					s += (long) a[y] * i;
					y ++;
				} else {
					long temp = s + sum2[y] + (long) i * sum[y];
					if (temp > ans) {
						ans = temp;
					}
					s += (long) a[y] * i;
					x ++;
				}
			} else {
				if (vis[x - 1][y]) {
					s += (long) b[y] * i;
					y ++;
				} else {
					long temp = s + sum1[y] + (long) i * sum[y];
					if (temp > ans) {
						ans = temp;
					}
					s += (long) b[y] * i;
					x --;
				}
			}
		}
		if (s > ans) {
			ans = s;
		}
		System.out.println(ans);

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScan in = new MyScan(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            int n = in.nextInt();
            long[][] data = new long[2][];
            data[0] = in.nl(n);
            data[1] = in.nl(n);

            long[][] t1 = new long[2][n + 1];
            long[] sum = new long[n + 1];
            for (int k = n - 1; k >= 0; k--) {
                t1[0][k] = t1[0][k + 1] + sum[k + 1];
                t1[1][k] = t1[1][k + 1] + sum[k + 1];

                t1[1][k] += 2 * (n - k) * data[0][k] - data[0][k];
                t1[0][k] += 2 * (n - k) * data[1][k] - data[1][k];

                sum[k] += sum[k + 1] + data[0][k] + data[1][k];
            }
            long best = 0;
            long moves = 0;

            long cur = 0;
            for (int s = 0; s < n; s++) {
                int k = s % 2;
                long mb = cur + t1[k][s] + moves * sum[s];

                best = Math.max(mb, best);

                cur += (moves) * data[k][s] + (moves + 1) * data[1 - k][s];
                moves += 2;
            }

            out.println(best);

        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public long[] nl(int n) {
            long[] k = new long[n];
            for (int i = 0; i < n; i++) {
                k[i] = nextLong();
            }
            return k;
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}


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());
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int[] bb = new int[n];
		for (int i = 0; i < n; i++)
			bb[i] = Integer.parseInt(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);
	}
}


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);
	}
}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayDeque;

public class C {

	static int R = 2;
	static int C;
	static long g[][];
	static long best = 0;
	public static void main(String[] args) {
		JS in = new JS();
		C = in.nextInt();
		g = new long[R][C];
		for(int i = 0; i < R; i++) {
			for(int j = 0; j < C; j++) g[i][j] = in.nextLong();
		}
		long cumSumR1[] = new long[C];
		long cumSumR2[] = new long[C];
		cumSumR1[0] = g[0][0];
		for(int i = 1; i < C; i++) cumSumR1[i] = cumSumR1[i-1]+g[0][i];
		cumSumR2[0] = g[1][0];
		for(int i = 1; i < C; i++) cumSumR2[i] = cumSumR2[i-1]+g[1][i];

		long sumR1_1[] = new long[C];
		long sumR2_1[] = new long[C];
		sumR1_1[0] = 0;
		for(int i = 1; i < C; i++) {
			sumR1_1[i] = sumR1_1[i-1]+g[0][i]*i;
		}

		sumR2_1[0] = g[1][C-1]*(long)(C);
		int id = 1;
		long mult = C+1;
		for(int i = C-2; i >= 0; i--) {
			sumR2_1[id] = sumR2_1[id-1]+g[1][i]*mult;
			id++;
			mult++;
		}

		long sumR1_2[] = new long[C];
		long sumR2_2[] = new long[C];
		sumR2_2[0] = g[1][0];
		for(int i = 1; i < C; i++) {
			sumR2_2[i] = sumR2_2[i-1] + g[1][i]*(i+1);
		}
		sumR1_2[0] = g[0][C-1]*(long)(C+1);
		id = 1;
		mult = C+2;
		for(int i = C-2; i >= 0; i--) {
			sumR1_2[id] = sumR1_2[id-1] + g[0][i]*mult;
			id++;
			mult++;
		}

		best = 0;
		ArrayDeque<state> q = new ArrayDeque<state>();
		q.add(new state(0,0,0,0));
		while(!q.isEmpty()) {
			state v = q.poll();
			if(v.c == C-1) {
				if((C%2 == 0 && v.r == 0) || (C%2==1&&v.r==1) ) {
					best = Math.max(best, v.mush);
					break;
				}
			}
			if(v.r == 0) {
				if(v.c%2 == 0) { //go down at the end and calc
					long res1 = sumR1_1[C-1] - sumR1_1[v.c];
					long et1 = (v.time+1) - (v.c+1);
					long cSum1 = cumSumR1[C-1] - cumSumR1[v.c];
					res1 += (cSum1*et1);

					long res2 = sumR2_1[C-1-v.c];
					long et2 = (v.time+(C-v.c)) - (C);
					long cSum2 = cumSumR2[C-1] - (v.c==0? 0 : cumSumR2[v.c-1]);
					res2 += (cSum2*et2);
					best = Math.max(best, v.mush+res1+res2);

					q.add(new state(1,v.c,v.time+1,v.mush + g[1][v.c]*(v.time+1)));
				}
				else { //go right at the end
					q.add(new state(0,v.c+1,v.time+1,v.mush + g[0][v.c+1]*(v.time+1)));
				}
			}
			else {
				if(v.c%2 == 0) { //go right at the end
					q.add(new state(1,v.c+1,v.time+1,v.mush + g[1][v.c+1]*(v.time+1)));
				}
				else {	//go up at the end and calc
					long res1 = sumR2_2[C-1] - sumR2_2[v.c];
					long et1 = (v.time+1) - (v.c+2);
					long cSum1 = cumSumR2[C-1] - cumSumR2[v.c];
					res1 += (cSum1*et1);

					long res2 = sumR1_2[C-1-v.c];
					long et2 = (v.time+(C-v.c)) - (C+1);
					long cSum2 = cumSumR1[C-1] - (v.c==0? 0 : cumSumR1[v.c-1]);
					res2 += (cSum2*et2);
					best = Math.max(best, v.mush+res1+res2);

					q.add(new state(0,v.c,v.time+1,v.mush+g[0][v.c]*(v.time+1)));
				}
			}

		}
		System.out.println(best);

	}

	static class state{
		int r,c;
		long time;
		long mush;
		public state(int rr, int cc, long tt, long mm) {
			r=rr;
			c=cc;
			time=tt;
			mush=mm;
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
		    while(c!='.'&&c!='-'&&(c <'0' || c>'9')) c = nextChar();
		    boolean neg = c=='-';
		    if(neg)c=nextChar();
		    boolean fl = c=='.';
		    double cur = nextLong();
		    if(fl) return neg ? -cur/num : cur/num;
		    if(c == '.') {
			double next = nextLong();
			return neg ? -cur-next/num : cur+next/num;
		    }
		    else return neg ? -cur : cur;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayDeque;

public class C {

	static int R = 2;
	static int C;
	static long g[][];
	static long best = 0;
	public static void main(String[] args) {
		JS in = new JS();
		C = in.nextInt();
		g = new long[R][C];
		for(int i = 0; i < R; i++) {
			for(int j = 0; j < C; j++) g[i][j] = in.nextLong();
		}
		long cumSumR1[] = new long[C];
		long cumSumR2[] = new long[C];
		cumSumR1[0] = g[0][0];
		for(int i = 1; i < C; i++) cumSumR1[i] = cumSumR1[i-1]+g[0][i];
		cumSumR2[0] = g[1][0];
		for(int i = 1; i < C; i++) cumSumR2[i] = cumSumR2[i-1]+g[1][i];

		long sumR1_1[] = new long[C];
		long sumR2_1[] = new long[C];
		sumR1_1[0] = 0;
		for(int i = 1; i < C; i++) {
			sumR1_1[i] = sumR1_1[i-1]+g[0][i]*i;
		}

		sumR2_1[0] = g[1][C-1]*(long)(C);
		int id = 1;
		long mult = C+1;
		for(int i = C-2; i >= 0; i--) {
			sumR2_1[id] = sumR2_1[id-1]+g[1][i]*mult;
			id++;
			mult++;
		}

		long sumR1_2[] = new long[C];
		long sumR2_2[] = new long[C];
		sumR2_2[0] = g[1][0];
		for(int i = 1; i < C; i++) {
			sumR2_2[i] = sumR2_2[i-1] + g[1][i]*(i+1);
		}
		sumR1_2[0] = g[0][C-1]*(long)(C+1);
		id = 1;
		mult = C+2;
		for(int i = C-2; i >= 0; i--) {
			sumR1_2[id] = sumR1_2[id-1] + g[0][i]*mult;
			id++;
			mult++;
		}

		best = 0;
		ArrayDeque<state> q = new ArrayDeque<state>();
		q.add(new state(0,0,0,0));
		while(!q.isEmpty()) {
			state v = q.poll();
			if(v.r == 1 && v.c == C-1) {
				best = Math.max(best, v.mush);
				break;
			}
			if(v.r == 0) {
				if(v.c%2 == 0) { //go down at the end and calc
					long res1 = sumR1_1[C-1] - sumR1_1[v.c];
					long et1 = (v.time+1) - (v.c+1);
					long cSum1 = cumSumR1[C-1] - cumSumR1[v.c];
					res1 += (cSum1*et1);

					long res2 = sumR2_1[C-1-v.c];
					long et2 = (v.time+(C-v.c)) - (C);
					long cSum2 = cumSumR2[C-1] - (v.c==0? 0 : cumSumR2[v.c-1]);
					res2 += (cSum2*et2);
					best = Math.max(best, v.mush+res1+res2);

					q.add(new state(1,v.c,v.time+1,v.mush + g[1][v.c]*(v.time+1)));
				}
				else { //go right at the end
					q.add(new state(0,v.c+1,v.time+1,v.mush + g[0][v.c+1]*(v.time+1)));
				}
			}
			else {
				if(v.c%2 == 0) { //go right at the end
					q.add(new state(1,v.c+1,v.time+1,v.mush + g[1][v.c+1]*(v.time+1)));
				}
				else {	//go up at the end and calc
					long res1 = sumR2_2[C-1] - sumR2_2[v.c];
					long et1 = (v.time+1) - (v.c+2);
					long cSum1 = cumSumR2[C-1] - cumSumR2[v.c];
					res1 += (cSum1*et1);

					long res2 = sumR1_2[C-1-v.c];
					long et2 = (v.time+(C-v.c)) - (C+1);
					long cSum2 = cumSumR1[C-1] - (v.c==0? 0 : cumSumR1[v.c-1]);
					res2 += (cSum2*et2);
					best = Math.max(best, v.mush+res1+res2);

					q.add(new state(0,v.c,v.time+1,v.mush+g[0][v.c]*(v.time+1)));
				}
			}

		}
		System.out.println(best);

	}

	static class state{
		int r,c;
		long time;
		long mush;
		public state(int rr, int cc, long tt, long mm) {
			r=rr;
			c=cc;
			time=tt;
			mush=mm;
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
		    while(c!='.'&&c!='-'&&(c <'0' || c>'9')) c = nextChar();
		    boolean neg = c=='-';
		    if(neg)c=nextChar();
		    boolean fl = c=='.';
		    double cur = nextLong();
		    if(fl) return neg ? -cur/num : cur/num;
		    if(c == '.') {
			double next = nextLong();
			return neg ? -cur-next/num : cur+next/num;
		    }
		    else return neg ? -cur : cur;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Mushrooms1016C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		long sum123[][] = new long[2][n];
		long sum111[][] = new long[2][n];
		long sum321[][] = new long[2][n];
		long ud[][] = new long[2][n];

		int a[][] = new int[2][n];
		for(int i = 0 ; i<2 ; i++)
			a[i] = na(n);

		long prev = 0;
		for(int i = 0 , j = 0 , ct = 0 ; i<n ; i++) {

			ud[j][i] = prev + ct*a[j][i];
			prev = ud[j][i];
			ct++;
			if(i%2 == 0) {
				j++;
			}
			else {
				j--;
			}

			ud[j][i] = prev + ct*a[j][i];
			prev = ud[j][i];
			ct++;
		}

		for(int i = 0 ; i<2 ; i++) {
			for(int j = n - 1; j >= 0; --j) {
				sum123[i][j] = (j+1 == n ? 0 : sum123[i][j + 1]) + (j) * 1l * a[i][j];
				sum321[i][j] = (j+1 == n ? 0 : sum321[i][j + 1]) + (n - j - 1) * 1l * a[i][j];
				sum111[i][j] = (j+1 == n ? 0 : sum111[i][j + 1]) + a[i][j];
			}
		}

		long res = 0;
		long max = 0;
//
//		display2D(sum123);
//		display2D(sum321);
//		display2D(sum111);

		for(int i = 1 , j = 0 ; j<n ; j++ , i ^= 1) {

			long left = sum123[i^1][j] + sum111[i^1][j]*1l*j;

			long right = sum321[i][j] + sum111[i][j] * 1l *(n+j);

			res = left + (j-1 < 0 ? 0 : ud[i^1][j-1])+ right;

			//out.println(i+" "+j+" "+(j-1 < 0 ? 0 : ud[i^1][j-1])+" "+left + " " + right );
			max = Math.max(max, res);
		}

		out.println(max);

	}

	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new Mushrooms1016C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	void display2D(long a[][]) {
		for(long i[] : a) {
			for(long j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Mushrooms1016C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		long sum123[][] = new long[2][n];
		long sum111[][] = new long[2][n];
		long sum321[][] = new long[2][n];
		long ud[][] = new long[2][n];

		int a[][] = new int[2][n];
		for(int i = 0 ; i<2 ; i++)
			a[i] = na(n);

		long prev = 0;
		for(int i = 0 , j = 0 , ct = 0 ; i<n ; i++) {

			ud[j][i] = prev + ct*1l*a[j][i];
			prev = ud[j][i];
			ct++;
			if(i%2 == 0) {
				j++;
			}
			else {
				j--;
			}

			ud[j][i] = prev + ct*1l*a[j][i];
			prev = ud[j][i];
			ct++;
		}

		for(int i = 0 ; i<2 ; i++) {
			for(int j = n - 1; j >= 0; --j) {
				sum123[i][j] = (j+1 == n ? 0 : sum123[i][j + 1]) + (j) * 1l * a[i][j];
				sum321[i][j] = (j+1 == n ? 0 : sum321[i][j + 1]) + (n - j - 1) * 1l * a[i][j];
				sum111[i][j] = (j+1 == n ? 0 : sum111[i][j + 1]) + a[i][j];
			}
		}

		long res = 0;
		long max = 0;
//
//		display2D(sum123);
//		display2D(sum321);
//		display2D(sum111);

		for(int i = 1 , j = 0 ; j<n ; j++ , i ^= 1) {

			long left = sum123[i^1][j] + sum111[i^1][j]*1l*j;

			long right = sum321[i][j] + sum111[i][j] * 1l *(n+j);

			res = left + (j-1 < 0 ? 0 : ud[i^1][j-1])+ right;

			//out.println(i+" "+j+" "+(j-1 < 0 ? 0 : ud[i^1][j-1])+" "+left + " " + right );
			max = Math.max(max, res);
		}

		out.println(max);

	}

	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new Mushrooms1016C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	void display2D(long a[][]) {
		for(long i[] : a) {
			for(long j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Mushrooms1016C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		int a[][] = new int[2][n];
		a[0] = na(n);
		a[1] = na(n);

		long dp[][] = new long[2][n];
		long max = 0;
		for(int i = 0 ; i<2 ; i++) {

			for(int j = 0 ; j<n ; j++) {
				if(i == 0 && j == 0) dp[i][j] = 0;
				else {
					int ct = 0;

					int x = 0 , y = 0;
					while(y<j) {
						if(x == 0) {
							dp[i][j] += ct*a[x][y];
							x++;
							ct++;
							dp[i][j] += ct*a[x][y];
							y++;
							ct++;
						}
						else {
							dp[i][j] += ct*a[x][y];
							x--;
							ct++;
							dp[i][j] += ct*a[x][y];
							y++;
							ct++;
						}
					}

					//out.println("zig "+dp[i][j]+" ct "+ct+" "+x+" "+y);

					if(x == i) {
						ct--;
						dp[i][j] -= ct*a[x][y-1];
						ct--;

						if(x == 0) {
							x++;
							ct++;
							for(int k = y ; k<n ; k++ , ct++) dp[i][j] += ct*a[x][k];

							x--;
							for(int k = n-1 ; k>j ; k-- , ct++) dp[i][j] += ct*a[x][k];

							dp[i][j] += ct*a[i][j];
						}
						else {
							x--;
							ct++;
							for(int k = y ; k<n ; k++ , ct++) dp[i][j] += ct*a[x][k];
							x++;
							for(int k = n-1 ; k>j ; k-- , ct++) dp[i][j] += ct*a[x][k];

							dp[i][j] += ct*a[i][j];
						}
					}
					else {
						if(x == 0) {
							for(int k = y ; k<n ; k++ , ct++) dp[i][j] += ct*a[x][k];
							x++;
							for(int k = n-1 ; k>j ; k-- , ct++) dp[i][j] += ct*a[x][k];
						}
						else {
							for(int k = y ; k<n ; k++ , ct++) dp[i][j] += ct*a[x][k];
							x--;
							for(int k = n-1 ; k>j ; k-- , ct++) dp[i][j] += ct*a[x][k];
						}

						dp[i][j] += ct*a[i][j];
					}

				}
				max = Math.max(max, dp[i][j]);
			}
		}

//		for(int i[] : dp) {
//			for(int j : i)
//				out.print(j+" ");
//			out.println();
//		}

		out.println(max);

	}

	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new Mushrooms1016C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}

	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Atharva Nagarkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        JoltyScanner in = new JoltyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, JoltyScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] grid = new int[2][n];
            for (int r = 0; r < 2; ++r) {
                for (int c = 0; c < n; ++c) {
                    grid[r][c] = in.nextInt();
                }
            }
            long best = 0;
            {
                long cur = 0;
                long t = 0;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[0][c];
                }
                for (int c = n - 1; c >= 0; --c, ++t) {
                    cur += t * grid[1][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 1;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[1][c];
                }
                for (int c = n - 1; c >= 1; --c, ++t) {
                    cur += t * grid[0][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 0;
                boolean down = true;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    down = !down;
                    ++t;
                }
                best = Math.max(best, cur);
            }
            {
                BIT2D bitUp = new BIT2D(2, n);
                BIT2D bitDown = new BIT2D(2, n);
                BIT2D sum = new BIT2D(2, n);
                for (int r = 0; r < 2; ++r) {
                    for (int c = 0; c < n; ++c) {
                        sum.update(r + 1, c + 1, grid[r][c]);
                    }
                }
                long[][] timeUp = new long[2][n];
                long[][] timeDown = new long[2][n];
                { //go right, then down, then left
                    long t = 0;
                    for (int c = 0; c < n; ++c, ++t) {
                        bitUp.update(1, c + 1, t * grid[0][c]);
                        timeUp[0][c] = t;
                    }
                    for (int c = n - 1; c >= 0; --c, ++t) {
                        bitUp.update(2, c + 1, t * grid[1][c]);
                        timeUp[1][c] = t;
                    }
                }
                { //go down, then right, then up, then left
                    long t = 1;
                    for (int c = 0; c < n; ++c, ++t) {
                        bitDown.update(2, c + 1, t * grid[1][c]);
                        timeDown[1][c] = t;
                    }
                    for (int c = n - 1; c >= 1; --c, ++t) {
                        bitDown.update(1, c + 1, t * grid[0][c]);
                        timeDown[0][c] = t;
                    }
                }
//            System.out.println("time down: " + Arrays.deepToString(timeDown));
                long cur = 0;
                boolean down = true;
                long t = 0;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    if (down) {
                        if (r == 0) {
                            long bb = cur + bitUp.query(r + 1, c + 1, 2, n) + (t - timeUp[r][c]) * sum.query(r + 1, c + 1, 2, n);
                            best = Math.max(best, bb);
                        } else {
                            long bb = cur + bitDown.query(r, c + 1, 2, n) + (t - timeDown[r][c]) * sum.query(r, c + 1, 2, n);
                            best = Math.max(best, bb);
                        }
                    }
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    ++t;
                    down = !down;
                }
            }
            out.println(best);
        }

    }

    static class JoltyScanner {
        public int BS = 1 << 16;
        public char NC = (char) 0;
        public byte[] buf = new byte[BS];
        public int bId = 0;
        public int size = 0;
        public char c = NC;
        public double num = 1;
        public BufferedInputStream in;

        public JoltyScanner(InputStream is) {
            in = new BufferedInputStream(is, BS);
        }

        public JoltyScanner(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            num = 1;
            boolean neg = false;
            if (c == NC) c = nextChar();
            for (; (c < '0' || c > '9'); c = nextChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = nextChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                num *= 10;
            }
            return neg ? -res : res;
        }

    }

    static class BIT2D {
        private long[][] tree;

        public BIT2D(int x, int y) {
            tree = new long[x + 1][y + 1];
        }

        public long query(int x, int y) {
            long val = 0;
            while (x > 0) {
                int y1 = y;
                while (y1 > 0) {
                    val += tree[x][y1];
                    y1 -= y1 & -y1;
                }
                x -= x & -x;
            }
            return val;
        }

        public long query(int start_x, int start_y, int end_x, int end_y) {
            return query(end_x, end_y) - query(start_x - 1, end_y) - query(end_x, start_y - 1) + query(start_x - 1, start_y - 1);
        }

        public void update(int x, int y, long val) {
            int y1;
            while (x < tree.length) {
                y1 = y;
                while (y1 < tree[x].length) {
                    tree[x][y1] += val;
                    y1 += (y1 & -y1);
                }
                x += (x & -x);
            }
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Atharva Nagarkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        JoltyScanner in = new JoltyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, JoltyScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] grid = new int[2][n];
            for (int r = 0; r < 2; ++r) {
                for (int c = 0; c < n; ++c) {
                    grid[r][c] = in.nextInt();
                }
            }
            long best = 0;
            {
                long cur = 0;
                long t = 0;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[0][c];
                }
                for (int c = n - 1; c >= 0; --c, ++t) {
                    cur += t * grid[1][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 1;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[1][c];
                }
                for (int c = n - 1; c >= 1; --c, ++t) {
                    cur += t * grid[0][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 0;
                boolean down = true;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    down = !down;
                    ++t;
                }
                best = Math.max(best, cur);
            }
            out.println(best);
        }

    }

    static class JoltyScanner {
        public int BS = 1 << 16;
        public char NC = (char) 0;
        public byte[] buf = new byte[BS];
        public int bId = 0;
        public int size = 0;
        public char c = NC;
        public double num = 1;
        public BufferedInputStream in;

        public JoltyScanner(InputStream is) {
            in = new BufferedInputStream(is, BS);
        }

        public JoltyScanner(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            num = 1;
            boolean neg = false;
            if (c == NC) c = nextChar();
            for (; (c < '0' || c > '9'); c = nextChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = nextChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                num *= 10;
            }
            return neg ? -res : res;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Atharva Nagarkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        JoltyScanner in = new JoltyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, JoltyScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] grid = new int[2][n];
            for (int r = 0; r < 2; ++r) {
                for (int c = 0; c < n; ++c) {
                    grid[r][c] = in.nextInt();
                }
            }
            long best = 0;
            {
                long cur = 0;
                long t = 0;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[0][c];
                }
                for (int c = n - 1; c >= 0; --c, ++t) {
                    cur += t * grid[1][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 1;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[1][c];
                }
                for (int c = n - 1; c >= 1; --c, ++t) {
                    cur += t * grid[0][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 0;
                boolean down = true;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    down = !down;
                    ++t;
                }
                best = Math.max(best, cur);
            }
            {
                BIT2D bitUp = new BIT2D(2, n);
                BIT2D bitDown = new BIT2D(2, n);
                BIT2D sum = new BIT2D(2, n);
                for (int r = 0; r < 2; ++r) {
                    for (int c = 0; c < n; ++c) {
                        sum.update(r + 1, c + 1, grid[r][c]);
                    }
                }
                long[][] timeUp = new long[2][n];
                long[][] timeDown = new long[2][n];
                {
                    long t = 0;
                    for (int c = 0; c < n; ++c, ++t) {
                        bitUp.update(1, c + 1, t * grid[0][c]);
                        timeUp[0][c] = t;
                    }
                    for (int c = n - 1; c >= 0; --c, ++t) {
                        bitUp.update(2, c + 1, t * grid[1][c]);
                        timeUp[1][c] = t;
                    }
                }
                {
                    long t = 0;
                    for (int c = 0; c < n; ++c, ++t) {
                        bitDown.update(2, c + 1, t * grid[1][c]);
                        timeDown[1][c] = t;
                    }
                    for (int c = n - 1; c >= 1; --c, ++t) {
                        bitDown.update(1, c + 1, t * grid[0][c]);
                        timeDown[0][c] = t;
                    }
                }
                long cur = 0;
                boolean down = true;
                long t = 0;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    ++t;
                    down = !down;
                    if (c < n && down) {
                        if (r == 0) {
                            long bb = cur + bitUp.query(r + 1, c + 1) - timeUp[r][c] * sum.query(r + 1, c + 1);
                            best = Math.max(best, bb);
                        } else {
                            long bb = cur + bitDown.query(r, c + 1) - timeDown[r][c] * sum.query(r, c + 1);
                            best = Math.max(best, bb);
                        }
                    }
                }
            }
            out.println(best);
        }

    }

    static class JoltyScanner {
        public int BS = 1 << 16;
        public char NC = (char) 0;
        public byte[] buf = new byte[BS];
        public int bId = 0;
        public int size = 0;
        public char c = NC;
        public double num = 1;
        public BufferedInputStream in;

        public JoltyScanner(InputStream is) {
            in = new BufferedInputStream(is, BS);
        }

        public JoltyScanner(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            num = 1;
            boolean neg = false;
            if (c == NC) c = nextChar();
            for (; (c < '0' || c > '9'); c = nextChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = nextChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                num *= 10;
            }
            return neg ? -res : res;
        }

    }

    static class BIT2D {
        private long[][] tree;

        public BIT2D(int x, int y) {
            tree = new long[x + 1][y + 1];
        }

        public long query(int x, int y) {
            long val = 0;
            while (x > 0) {
                int y1 = y;
                while (y1 > 0) {
                    val += tree[x][y1];
                    y1 -= y1 & -y1;
                }
                x -= x & -x;
            }
            return val;
        }

        public void update(int x, int y, long val) {
            int y1;
            while (x < tree.length) {
                y1 = y;
                while (y1 < tree[x].length) {
                    tree[x][y1] += val;
                    y1 += (y1 & -y1);
                }
                x += (x & -x);
            }
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            long[] a = new long[n];
            long[] b = new long[n];
            for (int i = 0; i < n; ++i) a[i] = in.ni();
            for (int i = 0; i < n; ++i) b[i] = in.ni();
            long[] pa = new long[n + 1];
            pa[n - 1] = a[n - 1];
            for (int i = n - 2; i > -1; --i) pa[i] = a[i] + pa[i + 1];
            long[] pb = new long[n + 1];
            pb[n - 1] = b[n - 1];
            for (int i = n - 2; i > -1; --i) pb[i] = b[i] + pb[i + 1];
            long[] down = new long[n];
            for (int i = n - 2; i > -1; --i) {
                down[i] = down[i + 1] + b[i + 1] + pb[i + 2] + pa[i + 2] + a[i + 1] * 2 * (n - i - 1);
            }
            long[] up = new long[n];
            for (int i = n - 2; i > -1; --i) {
                up[i] = up[i + 1] + a[i + 1] + pb[i + 2] + pa[i + 2] + b[i + 1] * 2 * (n - i - 1);
            }
            long curr = 0;
            long ans = Integer.MIN_VALUE;
            for (int i = 0; i < 2 * n; ++i) {
                int col = i / 2;
                int row = 1;
                if ((i - col) % 2 == 0) row = 0;
                if (row == 0) curr += i * (a[col]);
                else curr += i * (b[col]);
                long rem = 0;
                if (row == 0) rem = up[col] + i * (pb[col + 1] + pa[col + 1]);
                else rem = down[col] + i * (pb[col + 1] + pa[col + 1]);
                if (ans < rem + curr) ans = rem + curr;
            }
            long lul = up[0] + b[0] * (2 * n - 1);
            ans = Math.max(ans, lul);
            out.print(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


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

public class Main
{

	public static void main(String args[])
	{

		// int n,m;

	{

		Scanner sc= new Scanner(System.in);
		int n= sc.nextInt();
		int arr1[]= new int[n];
		// int pref1[]= new int[n];
		int suff1[]= new int[n];
		int arr2[]= new int[n];
		// int pref2[]= new int[n];
		int suff2[]= new int[n];

		for(int i=0;i<n;i++)
		{
			arr1[i]= sc.nextInt();
			// if(i==0)
			// 	pref1[i]=arr1[i];
			// else
			// 	pref1[i]=pref1[i-1]+arr1[i];
		}
		for(int i=0;i<n;i++)
		{
			arr2[i]= sc.nextInt();
			// if(i==0)
			// 	pref2[i]=arr2[i];
			// else
			// 	pref2[i]=pref2[i-1]+arr2[i];
		}

		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
				suff1[i]=arr1[i];
			else
				suff1[i]=suff1[i+1]+arr1[i];
		}

		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
				suff2[i]=arr2[i];
			else
				suff2[i]=suff2[i+1]+arr2[i];
		}

		int dp[][][]= new int[n][2][2];
		dp[n-1][0][0]=arr2[n-1];
		dp[n-1][1][0]=arr1[n-1];

		int sums[][]= new int[n][2];
		sums[n-1][0]=arr2[n-1];
		sums[n-1][1]= arr1[n-1];

		for(int i=n-2;i>=0;i--)
		{
			sums[i][0]=sums[i+1][0]+suff1[i+1]+suff2[i+1]+arr2[i]*(2*(n-i)-1);
			sums[i][1]=sums[i+1][1]+suff1[i+1]+suff2[i+1]+arr1[i]*(2*(n-i)-1);

		}

		// System.out.println(sums[0][1]);
		for(int i=n-2;i>=0;i--)
		{
			dp[i][1][1]=dp[i+1][1][0]+suff1[i+1]+suff2[i+1];
			dp[i][0][1]=dp[i+1][0][0]+suff1[i+1]+suff2[i+1];

			int val1=sums[i][0] ;
			int val2= dp[i][1][1] + suff2[i] + suff1[i+1];

			dp[i][0][0]=Math.max(val1, val2);

			val1= sums[i][1];
			val2=  dp[i][0][1] +suff1[i]+ suff2[i+1];

			dp[i][1][0]=Math.max(val1, val2);
		}

		// for(int i=0;i<n;i++)
		// {
		// 	System.out.println(dp[i][0][0] + "  " + sums[i][0]);
		// }
		System.out.println(dp[0][0][0]);

	}
}

}


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

public class Main
{

	public static void main(String args[])
	{

		// int n,m;

	{

		Scanner sc= new Scanner(System.in);
		int n= sc.nextInt();
		int arr1[]= new int[n];
		// int pref1[]= new int[n];
		long suff1[]= new long[n];
		int arr2[]= new int[n];
		// int pref2[]= new int[n];
		long suff2[]= new long[n];

		for(int i=0;i<n;i++)
		{
			arr1[i]= sc.nextInt();
			// if(i==0)
			// 	pref1[i]=arr1[i];
			// else
			// 	pref1[i]=pref1[i-1]+arr1[i];
		}
		for(int i=0;i<n;i++)
		{
			arr2[i]= sc.nextInt();
			// if(i==0)
			// 	pref2[i]=arr2[i];
			// else
			// 	pref2[i]=pref2[i-1]+arr2[i];
		}

		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
				suff1[i]=(long)arr1[i];
			else
				suff1[i]=(long)suff1[i+1]+(long)arr1[i];
		}

		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
				suff2[i]=(long)arr2[i];
			else
				suff2[i]=suff2[i+1]+(long)arr2[i];
		}

		long dp[][][]= new long[n][2][2];
		dp[n-1][0][0]=(long)arr2[n-1];
		dp[n-1][1][0]=(long)arr1[n-1];

		long sums[][]= new long[n][2];
		sums[n-1][0]=(long)arr2[n-1];
		sums[n-1][1]= (long)arr1[n-1];

		for(int i=n-2;i>=0;i--)
		{
			sums[i][0]=sums[i+1][0]+suff1[i+1]+suff2[i+1]+(long)arr2[i]*(long)(2*(n-i)-1);
			sums[i][1]=sums[i+1][1]+suff1[i+1]+suff2[i+1]+(long)arr1[i]*(long)(2*(n-i)-1);

		}

		// System.out.println(sums[0][1]);
		for(int i=n-2;i>=0;i--)
		{
			dp[i][1][1]=dp[i+1][1][0]+suff1[i+1]+suff2[i+1];
			dp[i][0][1]=dp[i+1][0][0]+suff1[i+1]+suff2[i+1];

			long val1=sums[i][0] ;
			long val2= dp[i][1][1] + suff2[i] + suff1[i+1];

			dp[i][0][0]=Math.max(val1, val2);

			val1= sums[i][1];
			val2=  dp[i][0][1] +suff1[i]+ suff2[i+1];

			dp[i][1][0]=Math.max(val1, val2);
		}

		// for(int i=0;i<n;i++)
		// {
		// 	System.out.println(dp[i][0][0] + "  " + sums[i][0]);
		// }
		System.out.println(dp[0][0][0]);

	}
}

}


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

public class Mainn {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt();
		int[][] arr = { scn.nextArray(n), scn.nextArray(n) };
		long[] topF = new long[n + 1], topS = new long[n + 1];

		int t = 0;
		for (int i = 0; i < n; i++) {
			topF[i] += t * 1L * arr[0][i];
			t++;
		}
		for (int i = n - 1; i >= 0; i--) {
			topF[i] += t * 1L * arr[1][i];
			t++;
		}
		t = 0;
		for (int i = 0; i < n; i++) {
			topS[i] += t * 1L * arr[1][i];
			t++;
		}
		for (int i = n - 1; i > 0; i--) {
			topS[i] += t * 1L * arr[0][i];
			t++;
		}
		for (int i = n - 1; i >= 0; i--) {
			topF[i] += topF[i + 1];
			topS[i] += topS[i + 1];
		}

		long[] add = new long[n + 1];
		for(int i = 0; i < n; i++) {
			add[i] = arr[0][i] + arr[1][i];
		}
		for(int i = n - 1; i >= 0; i--) {
			add[i] += add[i + 1];
		}

		long ans = Math.max(topF[0], topS[0]), curr = 0;
		int down = 0;
		t = 0;
		for (int i = 0, j = 0; i < n; i++, j++) {
			if (i != n - 1) {
				if (down == 0) {
					ans = Math.max(ans, curr + topF[i] + add[i] * 1L * j);
				} else {
					ans = Math.max(ans, curr + topS[i] + add[i] * 1L * j);
				}
			}
			curr += t * 1L * arr[down][i];
			t++;
			curr += t * 1L * arr[1 - down][i];
			t++;
			down = 1 ^ down;
		}
		ans = Math.max(ans, curr);

		out.println(ans);
	}

	void run() throws Exception {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) throws Exception {
		new Mainn().run();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());

		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}


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

public class Mainn {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt();
		int[][] arr = { scn.nextArray(n), scn.nextArray(n) };
		long[] topF = new long[n + 1], topS = new long[n + 1];

		int t = 0;
		for (int i = 0; i < n; i++) {
			topF[i] += t * 1L * arr[0][i];
			t++;
		}
		for (int i = n - 1; i >= 0; i--) {
			topF[i] += t * 1L * arr[1][i];
			t++;
		}
		t = 1;
		for (int i = 0; i < n; i++) {
			topS[i] += t * 1L * arr[1][i];
			t++;
		}
		for (int i = n - 1; i > 0; i--) {
			topS[i] += t * 1L * arr[0][i];
			t++;
		}
		for (int i = n - 1; i >= 0; i--) {
			topF[i] += topF[i + 1];
			topS[i] += topS[i + 1];
		}

		long ans = Math.max(topF[0], topS[0]), curr = 0;
		int down = 0;
		t = 0;
		for (int i = 0; i < n; i++) {
			ans = Math.max(ans, curr + topF[i]);
			curr += t * 1L * arr[down][i];
			t++;
			curr += t * 1L * arr[1 - down][i];
			t++;
			down = 1 ^ down;
		}
		ans = Math.max(ans, curr);

		out.println(ans);
	}

	void run() throws Exception {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) throws Exception {
		new Mainn().run();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());

		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}


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

public class Mainn {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt();
		int[][] arr = { scn.nextArray(n), scn.nextArray(n) };
		long[] topF = new long[n + 1], topS = new long[n + 1];

		int t = 0;
		for (int i = 0; i < n; i++) {
			topF[i] += t * 1L * arr[0][i];
			t++;
		}
		for (int i = n - 1; i >= 0; i--) {
			topF[i] += t * 1L * arr[1][i];
			t++;
		}
		t = 0;
		for (int i = 0; i < n; i++) {
			topS[i] += t * 1L * arr[1][i];
			t++;
		}
		for (int i = n - 1; i > 0; i--) {
			topS[i] += t * 1L * arr[0][i];
			t++;
		}
		for (int i = n - 1; i >= 0; i--) {
			topF[i] += topF[i + 1];
			topS[i] += topS[i + 1];
		}

		int[] add = new int[n + 1];
		for(int i = 0; i < n; i++) {
			add[i] = arr[0][i] + arr[1][i];
		}
		for(int i = n - 1; i >= 0; i--) {
			add[i] += add[i + 1];
		}

		long ans = Math.max(topF[0], topS[0]), curr = 0;
		int down = 0;
		t = 0;
		for (int i = 0, j = 0; i < n; i++, j++) {
			if (i != n - 1) {
				if (down == 0) {
					ans = Math.max(ans, curr + topF[i] + add[i] * 1L * j);
				} else {
					ans = Math.max(ans, curr + topS[i] + add[i] * 1L * j);
				}
			}
			curr += t * 1L * arr[down][i];
			t++;
			curr += t * 1L * arr[1 - down][i];
			t++;
			down = 1 ^ down;
		}
		ans = Math.max(ans, curr);

		out.println(ans);
	}

	void run() throws Exception {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) throws Exception {
		new Mainn().run();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());

		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class c{

	static void solve(){
		int n = ni();
		long[][] a = new long[2][n];
		for(int i=0;i<n;++i)a[0][i]=nl();
		for(int i=0;i<n;++i)a[1][i]=nl();

		long[] ue = new long[n];
		ue[n-1] = a[0][n-1]*(n-1) + a[1][n-1]*n;
		for(int i=n-2;i>=0;--i)ue[i] = ue[i+1] + a[0][i]*i + a[1][i]*(2*n-1-i);
		long[] sum = new long[n];
		sum[n-1] = a[0][n-1] + a[1][n-1];
		for(int i=n-2;i>=0;--i)sum[i] = sum[i+1] + a[0][i] + a[1][i];

		long[] sita = new long[n];
		sita[n-1] = a[1][n-1]*(n-1) + a[1][n-1]*n;
		for(int i=n-2;i>=0;--i)sita[i] = sita[i+1] + a[1][i]*i + a[0][i]*(2*n-1-i);

		long ans = 0;
		long cur = 0;
		for(int i=0;i<n;++i){
			if(i%2==0){
				ans = Math.max(ans, cur + ue[i] + sum[i]*i);
				cur += (2*i)*a[0][i] + (2*i+1)*a[1][i];
			}else{
				ans = Math.max(ans, cur + sita[i] + sum[i]*(i-1));
				cur += (2*i)*a[1][i] + (2*i+1)*a[0][i];
			}
		}

		out.println(ans);

	}

	public static void main(String[] args){
		 solve();
		 out.flush();
	 }
	 private static InputStream in = System.in;
	 private static PrintWriter out = new PrintWriter(System.out);

	 private static final byte[] buffer = new byte[1<<15];
	 private static int ptr = 0;
	 private static int buflen = 0;
	 private static boolean hasNextByte(){
		 if(ptr<buflen)return true;
		 ptr = 0;
		 try{
			 buflen = in.read(buffer);
		 } catch (IOException e){
			 e.printStackTrace();
		 }
		 return buflen>0;
	 }
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;}
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);}
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;}

	 private static double nd(){ return Double.parseDouble(ns()); }
	 private static char nc(){ return (char)skip(); }
	 private static String ns(){
		 StringBuilder sb = new StringBuilder();
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b);
		 return sb.toString();
	 }
	 private static int[] nia(int n){
		 int[] res = new int[n];
		 for(int i=0;i<n;++i)res[i]=ni();
		 return res;
	 }
	 private static long[] nla(int n){
		 long[] res = new long[n];
		 for(int i=0;i<n;++i)res[i]=nl();
		 return res;
	 }
	 private static int ni(){
		 int res=0,b;
		 boolean minus=false;
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
		 if(b=='-'){
			 minus=true;
			 b=readByte();
		 }
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
		 return minus ? -res:res;
	 }
	 private static long nl(){
		 long res=0,b;
		 boolean minus=false;
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
		 if(b=='-'){
			 minus=true;
			 b=readByte();
		 }
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
		 return minus ? -res:res;
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class c{

	static void solve(){
		int n = ni();
		long[][] a = new long[2][n];
		for(int i=0;i<n;++i)a[0][i]=nl();
		for(int i=0;i<n;++i)a[1][i]=nl();

		long[] uekara = new long[2*n];
		uekara[0]=a[0][0];
		for(int i=1;i<n;++i)uekara[i]=uekara[i-1]+a[0][i];
		for(int i=0;i<n;++i)uekara[n+i]=uekara[n+i-1]+a[1][n-1-i];
		long[] uekaidan = new long[2*n];
		for(int i=1;i<n;++i)uekaidan[i] = uekaidan[i-1] + i*a[0][i];
		for(int i=0;i<n;++i)uekaidan[n+i]=uekaidan[n+i-1] + (n+i)*a[1][n-1-i];
		long ans = uekaidan[2*n-1];
		long cur = 0;
		long t = 0;
		for(int i=2;i<n;i+=2){
			cur += t*a[0][i-2] + (t+1)*a[1][i-2] + (t+2)*a[1][i-1] + (t+3)*a[0][i-1];
			ans = Math.max(ans, cur+ uekaidan[2*n-1-i]-uekaidan[i-1] + (uekara[2*n-1-i]-uekara[i-1])*i);
			t+=4;
		}

		long[] sitakara = new long[2*n];
		sitakara[0]=a[1][0];
		for(int i=1;i<n;++i)sitakara[i]=sitakara[i-1]+a[1][i];
		for(int i=0;i<n;++i)sitakara[n+i]=sitakara[n+i-1]+a[0][n-1-i];
		long[] sitakaidan = new long[2*n];
		sitakaidan[0]=a[1][0];
		for(int i=1;i<n;++i)sitakaidan[i] = sitakaidan[i-1] + (i+1)*a[1][i];
		for(int i=0;i<n;++i)sitakaidan[n+i]=sitakaidan[n+i-1] + (n+i+1)*a[0][n-1-i];
		cur = a[1][0];
		t = 2;
		for(int i=1;i<n;i+=2){
			ans = Math.max(ans, cur + sitakaidan[2*n-1-i]-sitakaidan[i-1] + (sitakaidan[2*n-1-i]-sitakaidan[i-1])*(i-1));
			if(i+1<n){
				cur += t*a[1][i] + t*a[0][i] + t*a[0][i+1]+t*a[1][i+1];
				t+=4;
			}
		}
		out.println(ans);

	}

	public static void main(String[] args){
		 solve();
		 out.flush();
	 }
	 private static InputStream in = System.in;
	 private static PrintWriter out = new PrintWriter(System.out);

	 private static final byte[] buffer = new byte[1<<15];
	 private static int ptr = 0;
	 private static int buflen = 0;
	 private static boolean hasNextByte(){
		 if(ptr<buflen)return true;
		 ptr = 0;
		 try{
			 buflen = in.read(buffer);
		 } catch (IOException e){
			 e.printStackTrace();
		 }
		 return buflen>0;
	 }
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;}
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);}
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;}

	 private static double nd(){ return Double.parseDouble(ns()); }
	 private static char nc(){ return (char)skip(); }
	 private static String ns(){
		 StringBuilder sb = new StringBuilder();
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b);
		 return sb.toString();
	 }
	 private static int[] nia(int n){
		 int[] res = new int[n];
		 for(int i=0;i<n;++i)res[i]=ni();
		 return res;
	 }
	 private static long[] nla(int n){
		 long[] res = new long[n];
		 for(int i=0;i<n;++i)res[i]=nl();
		 return res;
	 }
	 private static int ni(){
		 int res=0,b;
		 boolean minus=false;
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
		 if(b=='-'){
			 minus=true;
			 b=readByte();
		 }
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
		 return minus ? -res:res;
	 }
	 private static long nl(){
		 long res=0,b;
		 boolean minus=false;
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
		 if(b=='-'){
			 minus=true;
			 b=readByte();
		 }
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
		 return minus ? -res:res;
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class c{

	static void solve(){
		int n = ni();
		long[][] a = new long[2][n];
		for(int i=0;i<n;++i)a[0][i]=nl();
		for(int i=0;i<n;++i)a[1][i]=nl();

		long[] ue = new long[n];
		ue[n-1] = a[0][n-1]*(n-1) + a[1][n-1]*n;
		for(int i=n-2;i>=0;--i)ue[i] = ue[i+1] + a[0][i]*i + a[1][i]*(2*n-1-i);
		long[] sum = new long[n];
		sum[n-1] = a[0][n-1] + a[1][n-1];
		for(int i=n-2;i>=0;--i)sum[i] = sum[i+1] + a[0][i] + a[1][i];

		long[] sita = new long[n];
		sita[n-1] = a[1][n-1]*(n) + a[0][n-1]*(n+1);
		for(int i=n-2;i>=0;--i)sita[i] = sita[i+1] + a[1][i]*(i+1) + a[0][i]*(2*n-i);

		long ans = 0;
		long cur = 0;
		for(int i=0;i<n;++i){
			if(i%2==0){
//				out.println(cur + ue[i] + sum[i]*i);
				ans = Math.max(ans, cur + ue[i] + sum[i]*i);
				cur += (2*i)*a[0][i] + (2*i+1)*a[1][i];
			}else{
//				out.println(cur + sita[i] + sum[i]*(i-1));
				ans = Math.max(ans, cur + sita[i] + sum[i]*(i-1));
				cur += (2*i)*a[1][i] + (2*i+1)*a[0][i];
			}
		}

		out.println(ans);

	}

	public static void main(String[] args){
		 solve();
		 out.flush();
	 }
	 private static InputStream in = System.in;
	 private static PrintWriter out = new PrintWriter(System.out);

	 private static final byte[] buffer = new byte[1<<15];
	 private static int ptr = 0;
	 private static int buflen = 0;
	 private static boolean hasNextByte(){
		 if(ptr<buflen)return true;
		 ptr = 0;
		 try{
			 buflen = in.read(buffer);
		 } catch (IOException e){
			 e.printStackTrace();
		 }
		 return buflen>0;
	 }
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;}
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);}
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;}

	 private static double nd(){ return Double.parseDouble(ns()); }
	 private static char nc(){ return (char)skip(); }
	 private static String ns(){
		 StringBuilder sb = new StringBuilder();
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b);
		 return sb.toString();
	 }
	 private static int[] nia(int n){
		 int[] res = new int[n];
		 for(int i=0;i<n;++i)res[i]=ni();
		 return res;
	 }
	 private static long[] nla(int n){
		 long[] res = new long[n];
		 for(int i=0;i<n;++i)res[i]=nl();
		 return res;
	 }
	 private static int ni(){
		 int res=0,b;
		 boolean minus=false;
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
		 if(b=='-'){
			 minus=true;
			 b=readByte();
		 }
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
		 return minus ? -res:res;
	 }
	 private static long nl(){
		 long res=0,b;
		 boolean minus=false;
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
		 if(b=='-'){
			 minus=true;
			 b=readByte();
		 }
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
		 return minus ? -res:res;
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = calc(1);
            int p1 = 1;
            int p2 = 2 * n;
            while (p2 - p1 >= 3) {
                int m1 = p1 + (p2 - p1) / 3;
                int m2 = p2 - (p2 - p1) / 3;
                if (calc(m1) > calc(m2)) {
                    p2 = m2;
                } else {
                    p1 = m1;
                }
            }
            ans = Math.max(ans, calc(p2));
            ans = Math.max(ans, calc((p2 + p1) / 2));
            ans = Math.max(ans, calc(p1));
            out.println(ans);
        }

        long calc(int pos) {
            long res = 0;
            int cur = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    res += (2 * i) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur, i + 1, i);
                    }
                    res += (2 * i + 1) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur, i + 1, i + 1);
                    }
                } else {
                    res += (2 * i) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur, i + 1, i);
                    }
                    res += (2 * i + 1) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur, i + 1, i + 1);
                    }
                }
            }
            return res;
        }

        long sumUp(int ind, int from, int to) {
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) a[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) b[i] * ind;
                ind++;
            }
            return res;
        }

        long sumDown(int ind, int from, int to) {
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) b[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) a[i] * ind;
                ind++;
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}