#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long double PI = 3.141592653589793;
const long long int inf = 1e18;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return ((a * b) / gcd(a, b));
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = ((x % p) * (x % p)) % p;
  }
  return res % p;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p) % p;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int a[5][n + 5];
  for (long long int i = 1; i <= 2; i++)
    for (long long int i1 = 1; i1 <= n; i1++) cin >> a[i][i1];
  long long int cnt[5][n + 5];
  long long int count = 0, sum = 0;
  for (long long int i = 1; i <= n; i++) {
    cnt[1][i] = count;
    sum += a[1][i] * count;
    count++;
  }
  for (long long int i = n; i >= 1; i--) {
    cnt[2][i] = count;
    sum += a[2][i] * count;
    count++;
  }
  long long int ans = -inf;
  long long int val = 0;
  long long int sum1 = 0;
  long long int suff[n + 5];
  suff[n] = a[1][n] + a[2][n];
  for (long long int i = n - 1; i >= 1; i--) {
    suff[i] = suff[i + 1] + a[1][i] + a[2][i];
  }
  for (long long int i = 1; i <= n; i += 2) {
    if (i == 1) {
      ans = max(ans, sum);
      continue;
    }
    sum1 += val * a[1][i - 2];
    val++;
    sum1 += val * a[2][i - 2];
    val++;
    sum1 += val * a[2][i - 1];
    val++;
    sum1 += val * a[1][i - 1];
    val++;
    sum -= cnt[1][i - 2] * a[1][i - 2];
    sum -= cnt[1][i - 1] * a[1][i - 1];
    sum -= cnt[2][i - 2] * a[2][i - 2];
    sum -= cnt[2][i - 1] * a[2][i - 1];
    ans = max(ans, sum + cnt[1][i] * suff[i] + sum1);
  }
  for (long long int i = 1; i <= n; i++) {
    swap(a[1][i], a[2][i]);
  }
  sum = 0;
  count = 1;
  for (long long int i = 1; i <= n; i++) {
    cnt[1][i] = count;
    sum += count * a[1][i];
    count++;
  }
  for (long long int i = n; i >= 2; i--) {
    cnt[2][i] = count;
    sum += count * a[2][i];
    count++;
  }
  sum1 = 0;
  val = 2;
  for (long long int i = 2; i <= n; i += 2) {
    if (i == 2) {
      ans = max(ans, sum);
      sum -= a[1][1];
      sum1 += a[1][1];
      continue;
    }
    sum1 += val * a[1][i - 2];
    val++;
    sum1 += val * a[2][i - 2];
    val++;
    sum1 += val * a[2][i - 1];
    val++;
    sum1 += val * a[1][i - 1];
    val++;
    sum -= cnt[1][i - 2] * a[1][i - 2];
    sum -= cnt[1][i - 1] * a[1][i - 1];
    sum -= cnt[2][i - 2] * a[2][i - 2];
    sum -= cnt[2][i - 1] * a[2][i - 1];
    ans = max(ans, sum + (val - cnt[1][i]) * suff[i] + sum1);
  }
  cout << ans;
  return 0;
}
