#include <bits/stdc++.h>
using namespace std;
const int MAX = 300005;
const int dx[4] = {0, 1, 0, 1}, dy[4] = {1, 0, -1, 0};
int n;
int a[MAX][2];
long long pre[MAX][2], sum[MAX][2], rsum[MAX][2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[j][i]);
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++) {
      pre[j][i] = pre[j - 1][i] + a[j][i];
      sum[j][i] = sum[j - 1][i] + (long long)j * a[j][i];
    }
    for (int j = n; j >= 1; j--)
      rsum[j][i] = rsum[j + 1][i] + (long long)(n - j + 1) * a[j][i];
  }
  long long ans = sum[n][0] - pre[n][0] + rsum[1][1] + pre[n][1] * (n - 1);
  long long res = 0;
  int x = 1, y = 1, cnt = 1;
  while (x <= n) {
    res += (long long)cnt * a[x][y];
    if (y == 0) {
      long long tmp =
          res + sum[n][0] - sum[x][0] + (cnt - x) * (pre[n][0] - pre[x][0]);
      tmp = tmp + rsum[x + 1][1] + (cnt + n - x) * (pre[n][1] - pre[x][1]);
      ans = max(ans, tmp);
    } else {
      long long tmp =
          res + sum[n][1] - sum[x][1] + (cnt - x) * (pre[n][1] - pre[x][1]);
      tmp = tmp + rsum[x + 1][0] + (cnt + n - x) * (pre[n][0] - pre[x][0]);
      ans = max(ans, tmp);
    }
    x = x + dx[cnt % 4], y = y + dy[cnt % 4];
    cnt++;
  }
  printf("%I64d\n", ans);
  return 0;
}
