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;
const int inf = INT_MAX;
const long long int INF = LLONG_MAX;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> b(n);
  for (long long int i = 0; i <= n - 1; i++) cin >> a[i];
  for (long long int i = 0; i <= n - 1; i++) cin >> b[i];
  vector<vector<long long int> > clk(2, vector<long long int>(n, 0));
  vector<vector<long long int> > clksum(2, vector<long long int>(n, 0));
  vector<vector<long long int> > aclk(2, vector<long long int>(n, 0));
  vector<vector<long long int> > aclksum(2, vector<long long int>(n, 0));
  long long int last = 0;
  long long int lastsum = 0;
  long long int count = 0;
  clk[0][0] = 0;
  for (long long int i = 0; i <= n - 1; i++) {
    last += count * a[i];
    lastsum = lastsum + a[i];
    count++;
    clk[0][i] = last;
    clksum[0][i] = lastsum;
  }
  for (long long int i = n - 1; i >= 0; i--) {
    last += count * b[i];
    lastsum = lastsum + b[i];
    count++;
    clk[1][i] = last;
    clksum[1][i] = lastsum;
  }
  count = 2;
  last = b[0];
  aclk[0][0] = 0;
  aclk[1][0] = b[0];
  aclksum[0][0] = a[0];
  aclksum[1][0] = a[0] + b[0];
  lastsum = a[0] + b[0];
  for (long long int i = 1; i <= n - 1; i++) {
    last += (count)*b[i];
    lastsum += b[i];
    count++;
    aclk[1][i] = last;
    aclksum[1][i] = lastsum;
  }
  for (long long int i = n - 1; i >= 1; i--) {
    last += (count)*a[i];
    lastsum += a[i];
    count++;
    aclk[0][i] = last;
    aclksum[0][i] = lastsum;
  }
  vector<vector<long long int> > zig(2, vector<long long int>(n, 0));
  last = 0;
  count = 0;
  for (long long int i = 0; i <= n - 1; i++) {
    if (i % 2 == 0) {
      last += count * a[i];
      count++;
      zig[0][i] = last;
      last += count * b[i];
      zig[1][i] = last;
      count++;
    } else {
      last += count * b[i];
      count++;
      zig[1][i] = last;
      last += count * a[i];
      zig[0][i] = last;
      count++;
    }
  }
  long long int ans = clk[1][0];
  for (long long int i = 0; i <= n - 1; i++) {
    if (i % 2 == 0) {
      long long int var = zig[1][i];
      if (i + 1 <= n - 1) {
        var += ((i + 1) * 2 - (i + 2)) * (aclksum[0][i + 1] - aclksum[1][i]) +
               aclk[0][i + 1] - aclk[1][i];
      }
      ans = max(ans, var);
    } else {
      long long int var = zig[0][i];
      if (i + 1 <= n - 1) {
        var += (i + 1) * (clksum[1][i + 1] - clksum[0][i]) + clk[1][i + 1] -
               clk[0][i];
      }
      ans = max(ans, var);
    }
  }
  cout << ans << endl;
}
