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.*;
import static java.lang.Math.*;
public class Main
{  
    static int n;
    static long a[],b[],suffsum[],dp[][],roundtrip[][];
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
       n = scan.nextInt();
        a = new long[n];
        b = new long[n];
        suffsum = new long[n+1];
        dp = new long[n][2];
        roundtrip = new long[n][2];
        for(int i=0;i<n;++i)
            a[i] = scan.nextInt();
        for(int i=0;i<n;++i)
            b[i] = scan.nextInt();
        roundtrip[n-1][0] = dp[n-1][0] = a[n-1]+b[n-1]*2;
        roundtrip[n-1][1] = dp[n-1][1] = b[n-1]+a[n-1]*2;
        suffsum[n-1] = a[n-1]+b[n-1];
        for(int i=n-2;i>=0;--i)
        {   
            suffsum[i] = suffsum[i+1]+a[i]+b[i];
            roundtrip[i][0] = roundtrip[i+1][0]+suffsum[i+1]+a[i]+b[i]*(n-i)*2;
            roundtrip[i][1] = roundtrip[i+1][1]+suffsum[i+1]+b[i]+a[i]*(n-i)*2;
            dp[i][0] = max( a[i] + b[i]*2 + dp[i+1][1] + suffsum[i+1]*2 , roundtrip[i][0] );
            dp[i][1] = max( b[i] + a[i]*2 + dp[i+1][0] + suffsum[i+1]*2 , roundtrip[i][1] );
        }
        System.out.println(dp[0][0]-suffsum[0]);
    }
}