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 implements Runnable {
    FastScanner sc;
    PrintWriter pw;
    
    final class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
 
        public long nlo() {
            return Long.parseLong(next());
        }
 
        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }
 
        public int ni() {
            return Integer.parseInt(next());
        }
 
        public String nli() {
            String line = "";
            if (st.hasMoreTokens()) line = st.nextToken();
            else try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            while (st.hasMoreTokens()) line += " " + st.nextToken();
            return line;
        }
 
        public double nd() {
            return Double.parseDouble(next());
        }
    }
    public static void main(String[] args) throws Exception
    {
        new Thread(null,new Solution(),"codeforces",1<<28).start();
    }
    public void run()
    {
        sc=new FastScanner();
        pw=new PrintWriter(System.out);
        try{
        solve();}
        catch(Exception e)
        {
            pw.println(e);
        }
        pw.flush();
        pw.close();
    }
    public long gcd(long a,long b)
    {
        return b==0L?a:gcd(b,a%b);
    }
    public long ppow(long a,long b,long mod)
    {
        if(b==0L)
        return 1L;
        long tmp=1;
        while(b>1L)
        {
            if((b&1L)==1)
            tmp*=a;
            a*=a;
            a%=mod;
            tmp%=mod;
            b>>=1;
        }
        return (tmp*a)%mod;
    }
    public long pow(long a,long b)
    {
        if(b==0L)
        return 1L;
        long tmp=1;
        while(b>1L)
        {
            if((b&1L)==1)
            tmp*=a;
            a*=a;
            b>>=1;
        }
        return (tmp*a);
    }
    public  int gcd(int x,int y)
    {
        return y==0?x:gcd(y,x%y);
    }
   
    //////////////////////////////////
    /////////////  LOGIC  ///////////
    ////////////////////////////////
   
    public void solve() throws Exception{
      int n=sc.ni();
      long[][] arr=new long[n][2];
      long[][] dp=new long[n][2];
      long sum=0,s=0;
      for(int i=0;i<n;i++)
      sum+=(arr[i][0]=sc.ni());
      for(int i=0;i<n;i++)
      sum+=(arr[i][1]=sc.ni());
      dp[n-1][0]=arr[n-1][1];
      dp[n-1][1]=arr[n-1][0];
      s=arr[n-1][0]+arr[n-1][1];
      for(int i=n-2;i>=0;i--){
          dp[i][0]=dp[i+1][0]+s+((long)(2*(n-i)-1))*arr[i][1];
          dp[i][1]=dp[i+1][1]+s+((long)(2*(n-i)-1))*arr[i][0];
          s+=(arr[i][0]+arr[i][1]);
      }
      long ans=0,p=0,tmp=0;
      for(int i=0;i<n;i++)
      {
        if(p==0){
            ans=Math.max(ans,tmp+((long)2*i)*sum+dp[i][0]);
            tmp+=(2*i*arr[i][0]+(2*i+1)*arr[i][1]);
            p=1;
        }
        else{
            ans=Math.max(ans,tmp+((long)2*i)*sum+dp[i][1]);
            tmp+=(2*i*arr[i][1]+(2*i+1)*arr[i][0]);
            p=0;
        }
        sum-=arr[i][0];
        sum-=arr[i][1];    
      }
      ans=Math.max(ans,tmp);
      pw.println(ans);
    }
}