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>
#pragma GCC optimize("Ofast", "no-stack-protector", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
using namespace std;
const long long MOD = 1e9 + 7;
long long a[2][300005], preSum[300005];
vector<int> cuts;
void build(int n) {
  preSum[0] = a[1][0];
  long long t = 2;
  for (int i = 1; i < n; i++) {
    preSum[i] = preSum[i - 1];
    if (i % 2)
      preSum[i] += a[1][i] * t + a[0][i] * (t + 1);
    else
      preSum[i] += a[0][i] * t + a[1][i] * (t + 1);
    t += 2;
  }
}
long long special(int n) {
  long long t = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    ans += t * a[0][i];
    t++;
  }
  for (int i = n - 1; i >= 0; i--) {
    ans += t * a[1][i];
    t++;
  }
  return ans;
}
int main() {
  int n;
  srand(time(0));
  while (~scanf("%d", &n)) {
    clock_t op = clock(), ed;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < n; j++) scanf("%lld", &a[i][j]);
    build(n);
    long long ans = special(n);
    for (int i = 0; i < n; i++) cuts.push_back(i);
    random_shuffle(cuts.begin(), cuts.end());
    for (auto cut : cuts) {
      long long now = preSum[cut];
      long long t = 2 * (cut + 1);
      if (cut % 2) {
        for (int i = cut + 1; i < n; i++) {
          now += t * a[0][i];
          t++;
        }
        for (int i = n - 1; i > cut; i--) {
          now += t * a[1][i];
          t++;
        }
      } else {
        for (int i = cut + 1; i < n; i++) {
          now += t * a[1][i];
          t++;
        }
        for (int i = n - 1; i > cut; i--) {
          now += t * a[0][i];
          t++;
        }
      }
      ed = clock();
      ans = max(ans, now);
      if (((double)(ed - op)) / CLOCKS_PER_SEC >= 1.995) break;
    }
    printf("%lld\n", ans);
  }
}
