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 len) {

    long ans = 0;
    long[] suffixArray1 = new long[len];
    long[] suffixArray2 = new long[len];
    long[] prefixArray = new long[len];
    long[] suffixArray = new long[len];
    long start = 0;

    for (int i = 0; i < len; i++) {
      boolean flag = i % 2 == 0;
      int i1 = flag ? 0 : 1;
      int i2 = flag ? 1 : 0;
      prefixArray[i] =
          start * glade[i1][i] + (start + 1) * glade[i2][i] + (i == 0 ? 0 : prefixArray[i - 1]);
      start += 2;
    }
    for (int i = 0; i < len; i++) {
      suffixArray[i] = glade[0][i] + glade[1][i] + (i == 0 ? 0 : suffixArray[i - 1]);
    }

    long r1 = 0;
    long r2 = 2 * len - 1;
    for (int i = 0; i < len; i++) {
      suffixArray1[i] = r1 * glade[0][i] + r2 * glade[1][i] + (i == 0 ? 0 : suffixArray1[i - 1]);
      r1++;
      r2--;
    }
    r1 = 2;
    r2 = 2 * len - 1;
    suffixArray2[0] = glade[1][0];
    for (int i = 1; i < len; i++) {
      suffixArray2[i] = suffixArray2[i - 1] + r2 * glade[0][i] + r1 * glade[1][i];
      r1++;
      r2--;
    }
    for (int i = 0; i < len; i += 2) {
      long temp =
          (i == 0 ? 0 : prefixArray[i - 1])
              + (i == 0
                  ? suffixArray1[len - 1]
                  : (suffixArray1[len - 1] - suffixArray1[i - 1])
                      + (i * (suffixArray[len - 1] - suffixArray[i - 1])));
      ans = Math.max(ans, temp);
//      System.out.println("First "+temp);
    }

    for (int i = 1; i < len; i += 2) {
      long temp =
          prefixArray[i - 1]
              + suffixArray2[len - 1]
              - suffixArray2[i - 1]
              + ((i - 1) * (suffixArray[len - 1] - suffixArray[i - 1]));
      ans = Math.max(ans, temp);
//      System.out.println("Second "+temp);
    }

    return ans;
  }
}
