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.BufferedReader;
// import java.io.FileInputStream;
// import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.sqrt;
import static java.util.Arrays.copyOf;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;
import static java.util.Collections.reverse;

public class Main {
    FastScanner in;
    PrintWriter out;

    private void solve() throws IOException {
        int n = in.nextInt();
        long[][] a = new long[2][n];
        for (int i = 0; i < 2; i++)
            for (int j = 0; j < n; j++)
                a[i][j] = in.nextLong();

        long[][] sum = new long[2][n];
        for (int i = 0; i < 2; i++)
            for (int j = 0; j < n; j++)
                sum[i][j] = (j > 0 ? sum[i][j - 1] : 0) + a[i][j];

        long[][] sumLR = new long[2][n];
        for (int i = 0; i < 2; i++)
            for (int j = n - 1; j >= 0; j--)
                sumLR[i][j] = (j + 1 < n ? sumLR[i][j + 1] : 0) + sum[i][n - 1] - sum[i][j] + a[i][j];

        long[][] sumRL = new long[2][n];
        for (int i = 0; i < 2; i++)
            for (int j = n - 1; j >= 0; j--)
                sumRL[i][j] = (j + 1 < n ? sumRL[i][j + 1] : 0) + a[i][j] * (n - j);

        long ans = 0, cur, p = 0;
        for (int i = 0; i < n; i++) {
            cur = p + (i + 1 < n ? sumLR[i % 2][i + 1] : 0) + (sum[i % 2][n - 1] - (i > 0 ? sum[i % 2][i - 1] : 0)) * i * 2
                    + sumRL[(i + 1) % 2][i] + (sum[(i + 1) % 2][n - 1] - (i > 0 ? sum[(i + 1) % 2][i - 1] : 0)) * (i * 2 + n - i - 1);
            ans = max(ans, cur);
            p += a[i % 2][i] * (i * 2) + a[(i + 1) % 2][i] * (i * 2 + 1);
        }

        out.println(ans);
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

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

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next().replace(',', '.'));
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }

    }

    private void run() throws IOException {
        in = new FastScanner(System.in); // new FastScanner(new FileInputStream(".in"));
        out = new PrintWriter(System.out); // new PrintWriter(new FileOutputStream(".out"));

        solve();

        out.flush();
        out.close();
    }

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