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;

public class Solution {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        long[][] field = new long[n + 1][2];
        for (int i = 1; i <= n; i++) {
            field[i][0] = in.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            field[i][1] = in.nextInt();
        }
        long[][] dp = new long[n + 1][2];
        long[][] sum = new long[n + 1][2];
        sum[n][0] = field[n][1];
        sum[n][1] = field[n][0];
        dp[n][0] = field[n][1];
        dp[n][1] = field[n][0];
        for(int k=0;k<2;k++){
            for(int i=n-1;i>0;i--){
                sum[i][k]=sum[i+1][k]+field[i+1][k]+field[i][k^1];
                dp[i][k]=field[i+1][k]+sum[i+1][k]+dp[i+1][k]+(2*n-2*i+1)*field[i][k^1];
            }
        }
        long ans=0;
        long zig=0;
        int k=0;
        int i=1;
        for(long counter=0;counter<2*n;counter++){
            zig+=field[i][k]*counter;
            if(counter%2==0){
                ans=Math.max(ans,zig+dp[i][k]+counter*sum[i][k]);
                k=k^1;
            }else {
                i++;
            }
        }
        out.print(ans);
        out.close();
    }

    private static boolean checkSubstring(int i, int n, int m, String s, String t) {
        if (i + m > n) return false;
        for (int k = 0; k < m; k++) {
            if (s.charAt(i + k) != t.charAt(k)) return false;
        }
        return true;
    }

    private static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;

        FastScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        String nextToken() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) return null;
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(nextToken());
        }

        long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }
    }
}
