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.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution 
{
static class InputReader
	{
	    private final InputStream stream;
	    private final byte[] buf = new byte[8192];
	    private int curChar, snumChars;

	    public InputReader(InputStream st) {
	      this.stream = st;
	    }

	    public int read() {
	      if (snumChars == -1)
	        throw new InputMismatchException();
	      if (curChar >= snumChars) {
	        curChar = 0;
	        try {
	          snumChars = stream.read(buf);
	        } catch (IOException e) {
	          throw new InputMismatchException();
	        }
	        if (snumChars <= 0)
	          return -1;
	      }
	      return buf[curChar++];
	    }

	    public int nextInt() {
	      int c = read();
	      while (isSpaceChar(c)) {
	        c = read();
	      }
	      int sgn = 1;
	      if (c == '-') {
	        sgn = -1;
	        c = read();
	      }
	      int res = 0;
	      do {
	        res *= 10;
	        res += c - '0';
	        c = read();
	      } while (!isSpaceChar(c));
	      return res * sgn;
	    }

	    public long nextLong() {
	      int c = read();
	      while (isSpaceChar(c)) {
	        c = read();
	      }
	      int sgn = 1;
	      if (c == '-') {
	        sgn = -1;
	        c = read();
	      }
	      long res = 0;
	      do {
	        res *= 10;
	        res += c - '0';
	        c = read();
	      } while (!isSpaceChar(c));
	      return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	      int a[] = new int[n];
	      for (int i = 0; i < n; i++) {
	        a[i] = nextInt();
	      }
	      return a;
	    }

	    public String readString() {
	      int c = read();
	      while (isSpaceChar(c)) {
	        c = read();
	      }
	      StringBuilder res = new StringBuilder();
	      do {
	        res.appendCodePoint(c);
	        c = read();
	      } while (!isSpaceChar(c));
	      return res.toString();
	    }

	    public String nextLine() {
	      int c = read();
	      while (isSpaceChar(c))
	        c = read();
	      StringBuilder res = new StringBuilder();
	      do {
	        res.appendCodePoint(c);
	        c = read();
	      } while (!isEndOfLine(c));
	      return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    private boolean isEndOfLine(int c) {
	      return c == '\n' || c == '\r' || c == -1;
	    }
	}
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		long[][] arr = new long[3][n+1];
		long[][] brr = new long[3][n+1];
		long[][] crr = new long[3][n+1];
                long[][] drr = new long[3][n+1];
                long[][] sum1 = new long[3][n+1];
                long[][] sum2 = new long[3][n+1];
		String[] str = (br.readLine()).trim().split(" ");
		for(int i=1;i<=n;i++)
			arr[1][i] = Integer.parseInt(str[i-1]);
		str = (br.readLine()).trim().split(" ");
		for(int i=1;i<=n;i++)
			arr[2][i] = Integer.parseInt(str[i-1]);
		int count = 0;
		for(int i=1;i<=n;i++)
		{
			if(i%2 != 0)
			{
				brr[1][i] = brr[1][i-1] + count*arr[1][i];
				count++;
				brr[2][i] = brr[1][i] + count*arr[2][i];
				count++;
			}
			else if(i%2 == 0)
			{
				brr[2][i] = brr[2][i-1] + count*arr[2][i];
				count++;
				brr[1][i] = brr[2][i] + count*arr[1][i];
				count++;
			}
		}
                count = 0;
                for(int i=1;i<=n;i++)
                {
                    crr[1][i] = crr[1][i-1] + count*arr[1][i];
                    count++;
                }
                crr[2][n] = crr[1][n] + count*arr[2][n];
                count++;
                for(int i=n-1;i>=1;i--)
                {
                    crr[2][i] = crr[2][i+1] + count*arr[2][i];
                    count++;
                }
                count = 0;
                for(int i=1;i<=n;i++)
                {
                    drr[2][i] = drr[2][i-1] + count*arr[2][i];
                    count++;
                }
                drr[1][n] = drr[2][n] + count*arr[1][n];
                count++;
                for(int i=n-1;i>=1;i--)
                {
                    drr[1][i] = drr[1][i+1] + count*arr[1][i];
                    count++;
                }
                for(int i=1;i<=n;i++)
                {
                    sum1[1][i] = sum1[1][i-1] + arr[1][i];
                }
                sum1[2][n] = sum1[1][n] + arr[2][n];
                for(int i=n-1;i>=1;i--)
                {
                    sum1[2][i] = sum1[2][i+1]+ arr[2][i];
                }
                for(int i=1;i<=n;i++)
                {
                    sum2[2][i] = sum2[2][i-1] + arr[2][i];
                }
                sum2[1][n] = sum2[2][n] + arr[1][n];
                for(int i=n-1;i>=1;i--)
                {
                    sum2[1][i] = sum2[1][i+1] + arr[1][i];
                }
                long ans = Integer.MIN_VALUE;
		/*for(int i=1;i<=2;i++)
		{
			for(int j=1;j<=n;j++)
				System.out.print(sum2[i][j] + " ");
			System.out.println();
		}*/
                for(int i=1;i<=n;i++)
                {
                    long temp = 0;
                    if(i%2 != 0)
                    {
                        temp = brr[1][i] + (crr[2][i] - crr[1][i]) 
                                + (i-1)*(sum1[2][i] - sum1[1][i]);
                    }
                    else if(i%2 == 0)
                    {
                        temp = brr[2][i] + (crr[1][i] - crr[2][i])
                                + (i-1)*(sum2[1][i] - sum2[2][i]);
                    }
                    if(temp > ans)
                    {
                        ans = temp;
                    }
                }
                System.out.println(ans);
                
    }
}