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.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
public class   cf913
{
  BufferedReader in;
  StringTokenizer as;
  int nums[],nums2[];
  long pfx1[], pfx2[];
  long topleft[], topright[], bottomleft[], bottomright[];
  public static void main (String[] args)
  {
    new cf913  ();
  }
  
  public cf913  ()
  {
    try
    {
      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      nums = new int [a];
      boolean debug = false;
      nums2 = new int [a];
      topleft = new long [a];
      topright = new long [a];
      bottomright = new long [a];
      pfx2 = new long [a];
      pfx1 = new long [a];
      bottomleft = new long [a];
      for(int x = 0;x<a;x++)
      {
        nums[x] = nextInt();
      }
      for(int  x = 0;x<a;x++)
      {
        nums2[x] = nextInt();
      }
      pfx1[0] = nums[0];
      pfx2[0] = nums2[0];
      topleft[0] = nums[0];
      bottomleft[0] = nums2[0];
      topright[a-1] = nums[a-1];
      bottomright[a-1] = nums2[a-1];
      for(int x = 1;x<a;x++)
      {
        pfx1[x] = pfx1[x-1] + nums[x];
        pfx2[x] = pfx2[x-1] + nums2[x]; 
      }
      for(int x = 1;x<a;x++)
      {
        topleft[x] = nums[x] *(x+1) + topleft[x-1];
        bottomleft[x] = nums2[x] *(x+1) + bottomleft[x-1];
      }
      for(int x = a-2;x>=0;x--)
      {
        topright[x] = nums[x] * (a-x) + topright[x+1];
        bottomright[x] = nums2[x] * (a-x) + bottomright[x+1];
      }
      long max = -12;
      long sofar = 0;
      for(int x = 0;x<a;x++)
      {
        long temp1 = sofar;
        int day = 2*x + 1;
        if(x % 2 == 0)
        {
          if(x!=0)
          {
            temp1 += (pfx1[a-1]-pfx1[x-1])* x;
          }
          if(x != 0)
            temp1 += (topleft[a-1] - topleft[x-1]);
          else
            temp1 += topleft[a-1];

          if(x!=0)
            temp1+= (pfx2[a-1] - pfx2[x-1]) * (a+x);
          else
            temp1 += pfx2[a-1] *(a+x);

          temp1 += bottomright[x];
          sofar += nums[x] * day + nums2[x] *(day+1);
          max = Math.max(temp1, max);
        }
        else if(x % 2 == 1)
        {
          temp1 += (pfx2[a-1] - pfx2[x-1]) * x;
          temp1 += (bottomleft[a-1] - bottomleft[x-1]);
          temp1 += (pfx1[a-1] - pfx1[x-1]) * (a+x);
          temp1 += topright[x];
          sofar += nums2[x] * day + nums[x] *  (day+1);
          max = Math.max(temp1, max);
          
        }
        //       if(debug)
        //       System.out.println(temp1 - pfx1[a-1] - pfx2[a-2]);
      }
      System.out.println(max- pfx1[a-1] - pfx2[a-1]);
      if (debug)
        for(int x = 0;x<a;x++)
      {
        System.out.print(bottomright[x] + " ");
      }
    }
    
    
    catch(IOException e)
    {
      
    }
  }
  
  
  
  
  
  
  
  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }
    
    
    return as.nextToken ();
  }
  
  
  
  long nextLong () throws IOException
  {
    return Long.parseLong (next ());
  }
  
  
  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }
  
  
  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }
  
  
  String nextLine () throws IOException
  {
    return in.readLine ().trim ();
  }
}