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