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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long[][] vals = new long[2][N];
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < N; j++) {
                    vals[i][j] = in.nextInt();
                }
            }
            long[] zig = new long[N];
            zig[0] = vals[1][0];
            for (int i = 1; i < N; i++) {
                if (i % 2 == 0) {
                    zig[i] = zig[i - 1] + (2 * i) * vals[0][i] + (2 * i + 1) * vals[1][i];
                } else {
                    zig[i] = zig[i - 1] + (2 * i) * vals[1][i] + (2 * i + 1) * vals[0][i];

                }
            }
            long max = begin(vals);

            long[] sumFrom = new long[N];
            sumFrom[N - 1] = 0;
            for (int i = N - 2; i >= 0; i--) {
                sumFrom[i] = sumFrom[i + 1] + vals[0][i + 1] + vals[1][i + 1];
            }
            long[] straightTop = new long[N];
            long[] straightBot = new long[N];
            for (int i = N - 2; i >= 0; i--) {
                straightTop[i] = straightTop[i + 1] - sumFrom[i + 1] + (2 * (i + 1)) * vals[0][i + 1] + (N - 1) * vals[1][i + 1];
            }
            for (int i = N - 2; i >= 0; i--) {
                straightBot[i] = straightBot[i + 1] - sumFrom[i + 1] + (2 * (i + 1)) * vals[1][i + 1] + (N - 1) * vals[0][i + 1];
            }
            for (int i = 0; i < N; i++) {
                if (i % 2 == 0) {
                    max = Math.max(max, zig[i] + straightBot[i]);
                } else {
                    max = Math.max(max, zig[i] + straightTop[i]);
                }
            }
            out.println(max);

        }

        long begin(long[][] vals) {
            long curI = 0;
            long sum = 0;
            for (int j = 0; j < vals[0].length; j++) {
                sum += curI * vals[0][j];
                curI++;
            }
            for (int j = vals[0].length - 1; j >= 0; j--) {
                sum += curI * vals[1][j];
                curI++;
            }
            return sum;
        }

    }

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

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

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

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

    }
}

