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 CoinsAndQueries {
    public static ArrayList<Integer>[] arr;
    public static int moves=0;
    static Scanner scan=new Scanner(System.in);
    public static void main(String[] args) {
        int n, m,sum1=0,sum2=0;
        n=scan.nextInt();
        int[] arr1=new int[n];
        int[] arr2=new int[n];
        int i;
     for(i=0;i<n;i++){
         int c=scan.nextInt();
         sum1+=i*c;
         arr1[i]=c;
     }   i=2*n-1;
     for(int j=0;j<n;j++){
         int c=scan.nextInt();
         sum1+=i--*c;
         arr2[j]=c;
     }int a=0,b=0;
     for(i=0;i<n/2;i++){
         sum2+=arr1[a++]*(4*i)+arr2[b++]*(4*i+1)+arr1[a++]*(4*i+3)+arr2[b++]*(4*i+2);
     }
     if(n%2!=0)
         sum2+=arr1[a]*(4*i)+arr2[b]*(4*i+1);
     if(sum2>sum1)
         sum1=sum2;
    System.out.print(sum1);
    }
}