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.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    /*Scanner in = new Scanner(System.in);
	    long a = in.nextLong(), b = in.nextLong(), c = in.nextLong();
	    double now = (double) (a * 2 + b * 3 + c * 4) / (a + b + c);
        System.out.println(now >= 3.5d ? (int)0 : (int)((1.5d * a + 0.5d * b - 0.5d * c) / 1.5d));*/
        new Main().mashrooms();
    }

    public void deadBook(){
        Scanner in = new Scanner(System.in);
        int days = in.nextInt(), namesPerPage = in.nextInt(), mod = 0;
        int [] a = new int[days];
        for (int i = 0; i < days; i++) {
            a[i] = in.nextInt();
            System.out.print((a[i] + mod) / namesPerPage + " ");
            mod = (a[i] + mod) % namesPerPage;
        }
    }

    class Node{
        int n, v;
        public Node(int n, int v) {
            this.n = n;
            this.v = v;
        }

        @Override
        public String toString() {
            return String.format("(%d - %d)", n, v);
        }
    }

    public void mashrooms(){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), c = 0, px = 0, py = 0;
        int [][] a = new int[2][n], v = new int[2][n];
        long ans1 = 0, ans2 = 0;
        for (int i = 0; i < n; i++) {
            a[0][i] = in.nextInt();
            ans1 += a[0][i] * c++;
        }
        for (int i = 0; i < n; i++) {
            a[1][i] = in.nextInt();
        }
        for (int i = n-1; i >= 0; i--) {
            ans1 += a[1][i] * c++;
        }
        c = 0;
        while (c < 2 * n){
            switch (c % 4) {
                case 0:
                    ans2 += a[py++][px] * c++;
                    break;
                case 1:
                    ans2 += a[py][px++] * c++;
                    break;
                case 2:
                    ans2 += a[py--][px] * c++;
                    break;
                case 3:
                    ans2 += a[py][px++] * c++;
                    break;
            }
        }
        System.out.println(Math.max(ans1, ans2));
        /*ArrayList<ArrayList<Node>> g = new ArrayList<>(2 * n);
        for (int i = 0; i < 2 * n; i++) {
            g.add(new ArrayList<>());
        }
        for (int i = 0; i < n; i++) {
            if(i == 0){
                g.get(i).add(new Node(i+1, a[0][i+1]));
                g.get(i).add(new Node(n+i, a[1][i]));
                g.get(n+i).add(new Node(i, a[0][i]));
                g.get(n+i).add(new Node(n+i+1, a[1][i+1]));
            }
            else if (i == n-1){
                g.get(i).add(new Node(i-1, a[0][i-1]));
                g.get(i).add(new Node(n+i, a[1][i]));
                g.get(n+i).add(new Node(i, a[0][i]));
                g.get(n+i).add(new Node(n+i-1, a[1][i-1]));
            }
            else{
                g.get(i).add(new Node(i-1, a[0][i-1]));
                g.get(i).add(new Node(i+1, a[0][i+1]));
                g.get(i).add(new Node(n+i, a[1][i]));
                g.get(n+i).add(new Node(i, a[0][i]));
                g.get(n+i).add(new Node(n+i-1, a[1][i-1]));
                g.get(n+i).add(new Node(n+1+i, a[1][i+1]));
            }
        }
        System.out.println(g);
        System.out.println(dfs(g, new int[2 * n], 0, 0, 1));*/
    }

    /*public static int dfs(ArrayList<ArrayList<Node>> g, int [] vis, int i, int ans, int c){
        if(vis[i] == 0){
            vis[i] = 1;
            int min = Integer.MAX_VALUE, pos = -100;
            for (Node nodes : g.get(i)){
                if (nodes.v < min) {
                    min = nodes.v;
                    pos = nodes.n;
                }
                dfs(g, vis, pos, ans+min*(c+1), c+1);
            }
        }
        return ans;
    }*/
}