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.StringTokenizer;

import static java.lang.Math.max;

public class Main {
    private static FastScanner in = new FastScanner();
    private static FastOutput out = new FastOutput();

    int n;
    int a[][];
    long[][] sum111;
    long[][] sum123;
    long[][] sum321;


    public void run() {
        n = in.nextInt();
        a = new int[2][n];

        sum111 = new long[2][n];
        sum123 = new long[2][n];
        sum321 = new long[2][n];

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

        for (int i = 0; i < 2; i++) {
            sum111[i][0] = a[i][0];
            for (int j = 1; j < n; j++) {
                sum111[i][j] = sum111[i][j - 1] + a[i][j];
            }

            sum123[i][n - 1] = a[i][n - 1];
            sum321[i][n - 1] = a[i][n - 1];

            for (int j = n - 2; j >= 0; j--) {
                long diff = sum_int(i, j + 1, n - 1);
                sum123[i][j] = sum123[i][j + 1];
                sum123[i][j] += diff;
                sum123[i][j] += a[i][j];

                sum321[i][j] = sum321[i][j + 1];
                sum321[i][j] += a[i][j] * (n - j);
            }
        }

        long k = 0;
        long prevRes = 0;
        long bestRes = -1;

        for (int i = 0, j = 0; j < n; j++, i ^= 1, k += 2) {
            long res = prevRes;
            long toEnd = sum123[i][j] + (k - 1) * sum_int(i , j, n - 1);
            long toBegin = sum321[i ^ 1][j] + (k - 1 + (n - j)) * sum_int(i ^ 1 , j, n - 1);

            res += toEnd + toBegin;
            bestRes = max(bestRes, res);

            prevRes += k * a[i][j] + (k + 1) * a[i ^ 1][j];
        }

        bestRes = max(bestRes, prevRes);

        out.print(bestRes);
    }

    private long sum_int(int i, int from, int to) {
        return sum111[i][to] - (from == 0 ? 0 : sum111[i][from - 1]);
    }

    public static void main(String[] args) {
        new Main().run();
        out.flush();
        out.close();
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner() {
        this(System.in);
    }

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

    FastScanner(File file) {
        try {
            br = new BufferedReader(new FileReader(file));
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

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

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

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

class FastOutput {
    private final BufferedWriter bf;


    public FastOutput(OutputStream outputStream) {
        bf = new BufferedWriter(new OutputStreamWriter(outputStream));
    }

    public FastOutput() {
        this(System.out);
    }

    private void printOne(Object s) {
        try {
            bf.write(s.toString());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void println(Object s) {
        printOne(s);
        printOne("\n");
    }

    public void print(Object ...os) {
        printd(" ", os);
    }

    public void printd(String delimiter, Object ...os) {
        for (Object o : os) {
            printOne(o);
            printOne(delimiter);
        }
    }

    public void flush() {
        try {
            bf.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void close() {
        try {
            bf.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}