6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

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

public class Main {
    private static class Solver {
        private void Solve() {
            int n = inp.nextInt();
            long[] a = new long[n + 1];
            long[] b = new long[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = inp.nextLong();
            }
            for (int i = 1; i <= n; ++i) {
                b[i] = inp.nextLong();
            }

            long[] s = new long[n + 1];
            for (int i = n; i >= 1; --i) {
                s[i] = (a[i] + b[i]);
                if (i < n) {
                    s[i] = s[i] + s[i + 1];
                }
            }

            long[] f = new long[n + 1];
            long[] g = new long[n + 1];
            f[n] = b[n];
            g[n] = a[n];
            for (int i = n - 1; i >= 1; --i) {
                int c = (n - i + 1) * 2 - 1;
                f[i] = f[i + 1] + s[i + 1] + b[i] * c;
                g[i] = g[i + 1] + s[i + 1] + a[i] * c;
            }

            long ans = 0;
            long sum = 0;
            long cnt = 0;
            ans = Math.max(ans, f[1]);
            for (int i = 1; i <= n; ++i) {
                if (i % 2 == 1) {
                    sum += a[i] * cnt++;
                    sum += b[i] * cnt++;
                    long val = sum + (i == n ? 0 : (g[i + 1] + s[i + 1] * cnt));
                    ans = Math.max(ans, val);
                } else {
                    sum += b[i] * cnt++;
                    sum += a[i] * cnt++;
                    long val = sum + (i == n ? 0 : (f[i + 1] + s[i + 1] * cnt));
                    ans = Math.max(ans, val);
                }
            }

            out.println(ans);
        }
        static InputReader inp;
        static PrintWriter out;
    }

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

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

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

        private int nextInt() {
            return Integer.parseInt(next());
        }
        private long nextLong() {
            return Long.parseLong(next());
        }
        private int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = nextInt();
            }
            return a;
        }
    }
    public static void main(String[] args) throws IOException {
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.setIn(new FileInputStream(new File("input.txt")));
        }
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Solver.inp = new InputReader(inputStream);
        Solver.out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.Solve();
        Solver.out.close();
    }
}