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 implements Runnable {

    int maxn = (int)3e5+111;
    int n,m,k;
    long leftToRight [][] = new long[2][maxn];
    long rightToLeft [][] = new long[2][maxn];
    long sumSuf[][] = new long[2][maxn];
    long a[][] = new long[2][maxn];

    void solve() throws Exception {
        n = in.nextInt();
        for (int i=0; i<n; i++) {
            a[0][i] = in.nextInt();
        }

        for (int i=0; i<n; i++) {
            a[1][i] = in.nextInt();
        }

        for (int i=0; i<2; i++) {
            for (int j=n-1; j>=0; j--) {
                leftToRight[i][j] = leftToRight[i][j+1] + a[i][j]*(j+1);
                rightToLeft[i][j] = rightToLeft[i][j+1] + a[i][j]*(n-j);
                sumSuf[i][j] = sumSuf[i][j+1] + a[i][j];
            }
        }

        int row = 0;
        long max = 0;
        long sum = 0;
        for (int j=0; j<n; j++) {
            long locMax = sum;
            locMax += leftToRight[row][j] + sumSuf[row][j]*j;
            locMax += rightToLeft[row^1][j] + sumSuf[row^1][j]*(n+j);
            max = Math.max(max, locMax);

            sum+=a[row][j]*(j*2+1);
            sum+=a[row^1][j]*(j*2+2);
            row ^= 1;
        }

        for (int i=0; i<n; i++) {
            max-=a[0][i] + a[1][i];
        }
        out.println(max);
    }


    class Pair {
        int x, y;

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

    String fileInName = "";

    boolean file = false;
    boolean isAcmp = false;

    static Throwable throwable;
    public static void main (String [] args) throws Throwable {
        Thread thread = new Thread(null, new Main(), "", (1 << 26));
        thread.start();
        thread.join();
        thread.run();
        if (throwable != null)
            throw throwable;
    }

    FastReader in;
    PrintWriter out;

    public void run() {
        String fileIn = "absum.in";
        String fileOut = "absum.out";

        try {
            if (isAcmp) {
                if (file) {
                    in = new FastReader(new BufferedReader(new FileReader(fileIn)));
                    out = new PrintWriter (fileOut);
                } else {
                    in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                    out = new PrintWriter(System.out);
                }
            } else if (file) {
                in = new FastReader(new BufferedReader(new FileReader(fileInName+".in")));
                out = new PrintWriter (fileInName + ".out");
            } else {
                in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(System.out);
            }

            solve();
        } catch(Exception e) {
            throwable = e;
        } finally {
            out.close();
        }

    }


}

class FastReader {
    BufferedReader bf;
    StringTokenizer tk = null;

    public FastReader(BufferedReader bf) {
        this.bf = bf;
    }

    public String nextToken () throws Exception {
        if (tk==null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(bf.readLine());
        }
        if (!tk.hasMoreTokens()) return nextToken();
        else
            return tk.nextToken();
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}