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.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().run(in, out);
        out.close();
    }

    public static long mod = 17352642619633L;

    int N;
    long[] a;
    long[] b;

    long[] fsumA;
    long[] fsumB;

    long[] bsumA;
    long[] bsumB;

    long[] psumA;
    long[] psumB;

    void run(FastScanner in, PrintWriter out) {

        N = in.nextInt();
        a = new long[N];
        b = new long[N];

        fsumA = new long[N+1];
        fsumB = new long[N+1];

        bsumA = new long[N+1];
        bsumB = new long[N+1];

        psumA = new long[N+1];
        psumB = new long[N+1];

        for (int i = 0; i < N; i++) a[i] = in.nextInt();
        for (int i = 0; i < N; i++) b[i] = in.nextInt();

        for (int i = N-1; i >= 0; i--) {
            fsumA[i] = a[i] + fsumA[i+1] + psumA[i+1];
            psumA[i] = psumA[i+1] + a[i];

            fsumB[i] = b[i] + bsumB[i+1] + psumB[i+1];
            psumB[i] = psumB[i+1] + b[i];

            bsumA[i] = a[i]*(N-i) + bsumA[i+1];
            bsumB[i] = b[i]*(N-i) + bsumB[i+1];
        }
        // System.out.println(Arrays.toString(fsumA));
        // System.out.println(Arrays.toString(fsumB));

        // System.out.println(Arrays.toString(bsumA));
        // System.out.println(Arrays.toString(bsumB));

        System.out.println(go(0, 0, 0));

    }

    long go(int i, int or, long t) {
        if (i == N) return 0;

        // collect at t
        if (or == 0) {
            // go down then right
            long cost1 = t*a[i] + (t+1)*b[i] + go(i+1, 1, t+2);

            // go right then down then come back
            int timeReachEnd = N-i;
            long cost2 = fsumA[i] + (t-1)*psumA[i]
                + bsumB[i] + (timeReachEnd-1)*psumB[i];

            return Math.max(cost1, cost2);
        } else {
            // go up then right
            long cost1 = t*b[i] + (t+1)*a[i] + go(i+1, 0, t+2);

            // go right then down then come back
            int timeReachEnd = N-i;
            long cost2 = fsumB[i] + (t-1)*psumB[i]
                + bsumA[i] + (timeReachEnd-1)*psumA[i];

            return Math.max(cost1, cost2);
        }

    }



    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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