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.*;
import java.io.*;

public class Shashank
{
    public static void main(String []args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        
        
        int n = Integer.parseInt(br.readLine());
        long[][] ab = new long[2][n + 2];
        long[][] f = new long[2][n + 2];
        long[] s = new long[n + 2];
        long[][] dp = new long[2][n + 2];
        
        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[0][i] = Long.parseLong(st.nextToken());
        
        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[1][i] = Long.parseLong(st.nextToken());
        
        for(int i = n; i > 0; i--)
        {
            s[i] += s[i + 1] + ab[0][i] + ab[1][i];
            f[0][i] = f[0][i + 1] + s[i + 1] + ab[1][i] * (2 * (n - i) + 1);
            f[1][i] = f[1][i + 1] + s[i + 1] + ab[0][i] * (2 * (n - i) + 1);
        }

        for(int i = n; i > 0; i--)
        {
            dp[0][i] = Math.max(f[0][i], dp[1][i + 1] + 2 * s[i + 1] + ab[1][i]);
            dp[1][i] = Math.max(f[1][i], dp[0][i + 1] + 2 * s[i + 1] + ab[0][i]);
        }
        
        System.out.println(dp[0][1]);
    }
}