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.*;
public class Solution {
      public static void main(String[] args) throws FileNotFoundException, IOException {
          Scanner sc=new Scanner(System.in);
          //Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream("C:/Users/HP LAPTOP/Downloads/A-small-practice.in"))));
          //BufferedWriter sp=new BufferedWriter(new FileWriter(new File("C:/Users/HP LAPTOP/Desktop/small_ans.txt")));
          //long startTime = System.nanoTime();
          int n=sc.nextInt();
          int[] a=new int[n];
          int[] b=new int[n];
          long sum2=0;
          int p2=0;
          for (int i=0;i<n ;i++ ) {
                  a[i]=sc.nextInt();
                  sum2+=(a[i]*p2);
                  p2++;
          }
          for (int i=0;i<n ;i++ ) {
                  b[i]=sc.nextInt();
          }
          for (int i=n-1;i>=0 ;i-- ) {
                  
                  sum2+=(b[i]*p2);
                  p2++;
          }
          //System.out.println(sum2);
          long sum1=0;
          int p=0;
          for (int i=0;i<n ;i++ ) {
                  //b[i]=sc.nextInt();
                  p++;
                  sum1+=(b[i]*p);
          }
          for (int i=n-1;i>0 ;i-- ) {
                  p++;
                  sum1+=(a[i]*p);
          }
          
          long sum3=0;
          int p3=0;
          for (int i=1;i<n ;i+=2 ) {
                  p3+=4;
                  if(i<n-1)
                  sum3+=(p3*a[i+1]+(p3-1)*a[i]);
                  else
                        sum3+=((p3-1)*a[i]);
          }
          p3=1;
          for (int i=0;i<n ;i+=2 ) {
                if(i<n-1)
                  sum3+=(p3*b[i]+(p3+1)*b[i+1]);
          else
                sum3+=(p3*b[i]);
                  p3+=4;
          }
          System.out.println(Math.max(Math.max(sum1,sum2),sum3));

      } 
}