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;
long long numa[300005], numb[300005], suma[300005], sumb[300005], num[300005],
    a[300005], b[300005];
int main() {
  long long n, ans = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    numa[i] = numa[i - 1] + a[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> b[i];
    numb[i] = numb[i - 1] + b[i];
  }
  for (long long i = 1; i <= n; i++) {
    suma[i] = suma[i - 1] + (i - 1) * a[i];
    sumb[i] = sumb[i - 1] + i * b[i];
  }
  long long cnt = 0, pos = 1;
  while (pos <= n) {
    if (pos % 2 == 1)
      num[pos] += num[pos - 1] + a[pos] * cnt + b[pos] * (cnt + 1);
    else
      num[pos] += num[pos - 1] + a[pos] * (cnt + 1) + b[pos] * cnt;
    cnt += 2;
    pos++;
  }
  for (long long i = 1; i <= n; i++) {
    long long x = num[i - 1];
    if (i % 2 == 1) {
      x += suma[n] - suma[i - 1] + (numa[n] - numa[i - 1]) * (i - 1);
      x += (numb[n] - numb[i - 1]) * (2 * n + i - 1) - (sumb[n] - sumb[i - 1]);
    } else {
      x += sumb[n] - sumb[i - 1] + (numb[n] - numb[i - 1]) * (i - 2);
      x += (numa[n] - numa[i - 1]) * (2 * n + i - 2) - (suma[n] - suma[i - 1]);
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
}
