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

#include <bits/stdc++.h>
using namespace std;
int Max(int a, int b) {
  if (a > b) return a;
  return b;
}
int Max3(int a, int b, int c) {
  if (Max(a, b) > c) return Max(a, b);
  return c;
}
int Max4(int a, int b, int c, int d) {
  if (Max(a, b) > Max(c, d)) return Max(a, b);
  return Max(c, d);
}
int Min(int a, int b) {
  if (a < b) return a;
  return b;
}
int Min3(int a, int b, int c) {
  if (Min(a, b) < c) return Min(a, b);
  return c;
}
int Min4(int a, int b, int c, int d) {
  if (Min(a, b) > Min(c, d)) return Min(a, b);
  return Min(c, d);
}
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int ab(int a) {
  if (a < 0) return -a;
  return a;
}
int ce(int a, int b) {
  int ans = a / b;
  if (a % b) return ans + 1;
  return ans;
}
long long arr[2][300005];
long long mic1[300005];
long long mic2[300005];
long long mic3[300005];
long long qs[300005];
int main() {
  long long n, ma = 0, sum, cnt, sum2;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &arr[0][i]);
  for (long long i = 1; i <= n; i++) scanf("%lld", &arr[1][i]);
  sum = cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (i % 2) {
      sum += arr[0][i] * cnt, ++cnt;
      sum += arr[1][i] * cnt, ++cnt;
    } else {
      sum += arr[1][i] * cnt, ++cnt;
      sum += arr[0][i] * cnt, ++cnt;
    }
    mic1[i] = sum;
  }
  sum = sum2 = 0;
  for (long long i = n; i >= 1; i--) {
    qs[i] = qs[i + 1] + arr[0][i] + arr[1][i];
    sum += i * arr[1][i];
    sum += ((2 * n) - i + 1) * arr[0][i];
    mic2[i] = sum;
    sum2 += (i - 1) * arr[0][i];
    sum2 += ((2 * n) - i) * arr[1][i];
    mic3[i] = sum2;
  }
  for (long long i = 0; i <= n; i++) {
    if (i % 2 && i != 0)
      ma = max(ma, mic1[i] + mic2[i + 1] + (i - 1) * qs[i + 1]);
    else
      ma = max(ma, mic1[i] + mic3[i + 1] + i * qs[i + 1]);
  }
  printf("%lld\n", ma);
  return 0;
}
