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.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int n) {

    int N = 300 * 1000 + 9;
    long[][] sum123 = new long[2][N];
    long[][] sum321 = new long[2][N];
    long[][] sum111 = new long[2][N];

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

    long res = 0, sum = 0;
    for (int i = 0, j = 0; j < n; ++j, i ^= 1) {
      long nres = sum;
      nres += sum123[i][j] + j * sum111[i][j];
      nres += sum321[i ^ 1][j] + (j + n) * sum111[i ^ 1][j];
      res = Math.max(res, nres);

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

    for (int j = 0; j < n; ++j) res -= glade[0][j] + glade[1][j];
    return res;
  }
}
