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.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 bacali
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(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, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            long[][] tab = new long[2][];
            tab[0] = in.nextLongArray(n);
            tab[1] = in.nextLongArray(n);
            long max = 0;
            long a = 0;
            long pasA = 0;
            for (int i = 0; i < n; i += 2) {
                long b = 0;
                long pasB = pasA;
                for (int j = i; j < n; j++) {
                    b += (pasB) * tab[0][j];
                    b += (2 * n - pasB - 1) * tab[1][j];
                    pasB++;
                }
                max = Math.max(max, a + b);
                a += pasA++ * tab[0][i];
                a += pasA++ * tab[1][i];
                if (i + 1 < n) {
                    a += pasA++ * tab[1][i + 1];
                    a += pasA++ * tab[0][i + 1];
                }
            }
            max = Math.max(max, a);
            a = 0;
            pasA = 1;
            for (int i = 0; i < n; i += 2) {
                long b = 0;
                long pasB = pasA;
                for (int j = i; j < n; j++) {
                    b += (pasB) * tab[1][j];
                    if (j > i) {
                        b += (2 * n - pasB + 1) * tab[0][j];
                    }
                    pasB++;
                }
                max = Math.max(max, a + b);
                a += pasA++ * tab[1][i];
                if (i + 1 < n) {
                    a += pasA++ * tab[1][i + 1];
                    a += pasA++ * tab[0][i + 1];
                }
                if (i + 2 < n) {
                    a += pasA++ * tab[0][i + 2];
                }
            }
            max = Math.max(max, a);
            out.println(max);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

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

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

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

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

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

    }
}

