#include <bits/stdc++.h>
using namespace std;
long long dp[300010], tmp[300010][2];
int a[300010], b[300010];
long long sum[300010][2];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = n; i; i--) {
    sum[i][0] = sum[i + 1][0] + a[i];
    sum[i][1] = sum[i + 1][1] + b[i];
  }
  for (int i = n; i; i--) {
    int x = (n - i + 1) * 2 - 1;
    tmp[i][0] =
        tmp[i + 1][0] + sum[i + 1][0] + sum[i + 1][1] + (long long)x * b[i];
    tmp[i][1] =
        tmp[i + 1][1] + sum[i + 1][1] + sum[i + 1][0] + (long long)x * a[i];
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    int x = (i - 1) * 2;
    if (i % 2)
      dp[i] += (long long)x * a[i] + (long long)(x + 1) * b[i];
    else
      dp[i] += (long long)x * b[i] + (long long)(x + 1) * a[i];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long val = dp[i];
    int x = i * 2;
    if (i % 2)
      val += tmp[i + 1][1] + (long long)x * (sum[i + 1][0] + sum[i + 1][1]);
    else
      val += tmp[i + 1][0] + (long long)x * (sum[i + 1][0] + sum[i + 1][1]);
    ans = max(ans, val);
  }
  ans = max(ans, tmp[1][0]);
  cout << ans << endl;
}
