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 Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

		int n = reader.nextInt();
		long[][] a = new long[2][n];

		for (int j=0; j<2; j++)
			for (int i=0; i<n; i++)
				a[j][i] = reader.nextInt();
		

		long[][] sum123 = new long[2][n+1];
		long[][] sum321 = new long[2][n+1];
		long[][] sum111 = new long[2][n+1];

		for (int i=0; i<2; i++)
			for (int j=n-1; j>=0; j--)
			{
				sum123[i][j] = sum123[i][j+1] + (j+1)*a[i][j];
				sum321[i][j] = sum321[i][j+1] + (n-j)*a[i][j];
				sum111[i][j] = sum111[i][j+1] + a[i][j];
			}

		long res=0, sum=0;

		for (int j=0, i=0; j<n; j++, i^=1)
		{
			long nres = sum;

			nres += sum123[i][j] + j*sum111[i][j];
			nres += sum321[i^1][j] + (n+j)*sum111[i^1][j];

			res = Math.max(res, nres);

			sum += (2*j+1)*a[i][j];
			sum += (2*j+2)*a[i^1][j];
		}

		for (int i=0; i<2; i++)
			for (int j=0; j<n; j++)
				res -= a[i][j];

		writer.println(res);
		writer.close();
	}

	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;
		}
	}
}