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.*;
public class C1016 
{
    public static void main(String args[])throws IOException
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[][]=new int[2][n+1];
        long sum[]=new long[2*n +1];
        long cumu[]=new long[2*n+1];
        long sum2[]=new long[2*n +1];
        long cumu2[]=new long[2*n+1];
        int c=0;
        for(int i=0;i<2;i++)
        {
            for(int j=1;j<=n;j++)
            {
                arr[i][j]=sc.nextInt();
                if(i==0)
                {
                    sum[j]=sum[j-1]+arr[i][j];
                    cumu[j]=cumu[j-1]+(1L*c*arr[i][j]);
                    c++;
                }
            }
            if(i==1)
            {
                int cc=1;
                for(int j=n;j>=1;j--)
                {
                    sum[n+cc]=sum[n+cc-1]+arr[i][j];
                    cumu[n+cc]=cumu[n+cc-1]+(1L*c*arr[i][j]);
                    c++;cc++;
                }
            }
        }
        c=1;
        for(int j=1;j<=n;j++)
        {
            sum2[j]=sum2[j-1]+arr[1][j];
            cumu2[j]=cumu2[j-1]+(1L*c*arr[1][j]);
            c++;
        }
        for(int j=n;j>=1;j--)
        {
            sum2[c]=sum2[c-1]+arr[0][j];
            cumu2[c]=cumu2[c-1]+(1L*c*arr[0][j]);
            c++;
        }
        /*for(int i=1;i<=2*n;i++)
        {
            System.out.println(i+" "+sum2[i]+" "+cumu2[i]);
        }*/
        if(n==1)
            System.out.println(arr[1][1]);
        else
        {
            long dp[][]=new long[2][n+1];
            long dp2[][]=new long[2][n+1];
            long cou=1,mult=1,co=0;
            dp[1][0]=cumu[2*n];
            long max=cumu[2*n];
            for(int i=1;i<=n;i++)
            {
                if(i%2==0)
                {
                    dp[0][i]=dp[0][i-1]+(cou*arr[0][i])+((cou-1)*arr[1][i]);
                    cou+=2;
                    if(i!=n)
                    {
                        int lim=n+n-i;
                        dp[1][i]=dp[0][i]+(cumu[lim]-cumu[i])+(1L*i*(sum[lim]-sum[i]));
                    }
                }
                else
                {
                    dp[0][i]=dp[0][i-1]+(cou*arr[1][i])+((cou-1)*arr[0][i]);
                    dp2[0][i]=dp[0][i];
                    cou+=2;
                    if(i!=n)
                    {
                        int lim=n+n-i;
                        dp2[1][i]=dp2[0][i]+(cumu2[lim]-cumu2[i])+(1L*(i-1)*(sum2[lim]-sum2[i]));
                        //System.out.println(i+" "+(cumu2[lim]-cumu2[i])+" "+(sum2[lim]-sum2[i]));
                    }
                    
                }
                //System.out.println(dp[0][i]+" "+dp2[1][i]);
                max=Math.max(max,Math.max(dp[1][i],dp2[1][i]));
            }
            max=Math.max(max,dp[0][n]);
            System.out.println(max);
        }
    }
}
