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.*;
public class A{
    public static void main(String arg[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s[] = new int[n+1];
        int a[][] = new int[2][n+1];
        for(int i=0;i<n;i++){
            a[0][i] = sc.nextInt();
            s[i]+=a[0][i];
        }
        for(int i=0;i<n;i++){
            a[1][i] = sc.nextInt();
            s[i]+=a[1][i];
        }
        int d[][] = new int[2][n+1];
        for(int i=n-1;i>=0;i--){
            s[i]+=s[i+1];
            d[0][i]=d[0][i+1]+a[1][i]*(2*(n-i)-1)+s[i+1];
            d[1][i]=d[1][i+1]+a[0][i]*(2*(n-i)-1)+s[i+1];
        }
        int cur=0,ans=0,tim=-1;
        for(int i=0;i<=n;i++){
            if(i%2==0){
                tim++;
                ans=Math.max(ans,cur+d[0][i]+s[i]*tim);
                cur+=a[0][i]*tim;
                tim++;
                cur+=a[1][i]*tim;
            }
            else{
                tim++;
                ans=Math.max(ans,cur+d[1][i]+s[i]*tim);
                cur+=a[1][i]*tim;
                tim++;
                cur+=a[0][i]*tim;
            }
        }
        System.out.println(ans);
    }
}
