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.awt.List;
import java.awt.Polygon;
import java.awt.geom.Area;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.function.BinaryOperator;

public class WCS {

	public static void main(String[] args) {
		int n = in.nextInt();
		long[][] grid = new long[2][n];
		for(int i = 0; i < 2; i ++)
			for(int j = 0; j < n; j ++)
				grid[i][j] = in.nextLong();
		long[][] sum1 = new long[2][n];
		for(int i = 0; i < n; i ++)
			sum1[0][i] = grid[0][i] + (i > 0 ? sum1[0][i - 1] : 0);
		for(int i = n - 1; i >= 0; i --)
			sum1[1][i] = grid[1][i] + (i < n - 1 ? sum1[1][i + 1] : sum1[0][n - 1]);
		long[][] sum2 = new long[2][n];
		for(int i = 0; i < n; i ++)
			sum2[0][i] = i * grid[0][i] + (i > 0 ? sum2[0][i - 1] : 0);
		for(int i = n - 1; i >= 0; i --)
			sum2[1][i] = (n + (n - 1 - i)) * grid[1][i] + (i < n - 1 ? sum2[1][i + 1] : sum2[0][n - 1]);
		long[][] sum3 = new long[2][n];
		for(int i = 0; i < n; i ++)
			sum3[1][i] = grid[1][i] + (i > 0 ? sum3[1][i - 1] : 0);
		for(int i = n - 1; i >= 0; i --)
			sum3[0][i] = grid[0][i] + (i < n - 1 ? sum3[0][i + 1] : sum3[1][n - 1]);
		long[][] sum4 = new long[2][n];
		for(int i = 0; i < n; i ++)
			sum4[1][i] = i * grid[1][i] + (i > 0 ? sum4[1][i - 1] : 0);
		for(int i = n - 1; i >= 0; i --)
			sum4[0][i] = (n + (n - 1 - i)) * grid[0][i] + (i < n - 1 ? sum4[0][i + 1] : sum4[1][n - 1]);
		long current = 0;
		long time = 0;
		long ans = 0;
		for(int i = 0; i < n; i ++) {
			if(i % 2 == 0) {
				ans = Math.max(ans, current + sum2[1][i] - (i > 0 ? sum2[0][i - 1] : 0) + (sum1[1][i] - (i > 0 ? sum1[0][i - 1] : 0)) * (time - i));
				//System.out.println(i + " " + 0 + " " + ans);
				current += time * grid[0][i];
				current += (time + 1) * grid[1][i];
			} else {
				ans = Math.max(ans, current + sum4[0][i] - (i > 0 ? sum4[1][i - 1] : 0) + (sum3[0][i] - (i > 0 ? sum3[1][i - 1] : 0)) * (time - i));
				//System.out.println(i + " " + 0 + " " + ans);
				current += (time + 1) * grid[0][i];
				current += time * grid[1][i];
			}
			//System.out.println(current);
			time += 2;
		}
		System.out.println(ans);
	}
	
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
	
    public static FastReader in = new FastReader();
}