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();
            int[][] a = new int[2][n];
            for (int i = 0; i < 2; i++)
                for (int j = 0; j < n; j++)
                    a[i][j] = in.nextInt();


            long time = 0;
            long total = 0;
            long cur = 0;
            int i = 0;
            int j = 0;
            while (n > 0) {
                total = Math.max(total, func(i, j, time, a, n) + cur);
                cur += time++ * a[i][j];
                i = (i + 1) % 2;
                cur += time++ * a[i][j];
                j = (j + 1);
                n--;
            }
            total = Math.max(total, cur);

            out.println(total);
        }

        private long func(int i, int j, long time, int[][] a, int n) {
            long num = 0;
            for (int k = j; k < n; k++)
                num += a[i][k] * time++;
            i = (i + 1) % 2;
            for (int k = n - 1; k >= j; k--)
                num += a[i][k] * time++;
            return num;
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        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());
        }

    }
}

