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 Vadim Semenov
 */
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 final class TaskC {
        public void solve(int __, InputReader in, PrintWriter out) {
            int length = in.nextInt();
            long[][] table = in.nextLongTable(2, length);
            long[][] mul = new long[2][length + 1];
            long[][] add = new long[2][length + 1];
            for (int i = 0; i < 2; ++i) {
                for (int j = length - 1; j >= 0; --j) {
                    mul[i][j] = mul[i][j + 1] + (j + 1) * table[i][j];
                    add[i][j] = add[i][j + 1] + table[i][j];
                }
            }
            long have = 0;
            long answer = 0;
            for (int i = 0; i < length; ++i) {
                for (int j = 0, currentRow = i % 2; j < 2; ++j, currentRow ^= 1) {
                    int nextRow = currentRow ^ 1;
                    int currentTime = i * 2 + j;
                    int nextTime = currentTime + (length - i);
                    long current = have +
                            (currentTime - i - 1) * add[currentRow][i] + mul[currentRow][i] +
                            (nextTime + length) * add[nextRow][i + 1] - mul[nextRow][i + 1];
                    if (j == 0) {
                        current += (2 * length - 1) * table[nextRow][i];
                    }
                    answer = Math.max(answer, current);
                    have += currentTime * table[currentRow][i];
                }
            }
            out.println(Math.max(answer, have));
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public long[][] nextLongTable(int rows, int columns) {
            long[][] table = new long[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextLong();
                }
            }
            return table;
        }

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

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}

