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 OO = 1e9 + 7;
const int MOD = 1e9 + 7;
const int N = 3e5 + 7;
long long a[N];
long long b[N];
long long suma12[N], suma21[N];
long long sumb12[N], sumb21[N];
long long a12[N];
long long b12[N];
long long a21[N];
long long b21[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  long long cnt = 0;
  for (int i = n; i >= 1; i--) {
    suma12[i] = suma12[i + 1] + a[i];
    sumb12[i] = sumb12[i + 1] + b[i];
    a12[i] = a12[i + 1] + suma12[i + 1];
    b12[i] = b12[i + 1] + sumb12[i + 1];
    suma21[i] = suma21[i + 1] + a[i];
    sumb21[i] = sumb21[i + 1] + b[i];
    a21[i] = a21[i + 1] + a[i] * cnt;
    b21[i] = b21[i + 1] + b[i] * cnt;
    cnt++;
  }
  long long t = 0;
  long long sum = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      long long tmp = a12[i] + (suma12[i] * t);
      tmp += b21[i] + (sumb21[i] * (t + n - i + 1));
      tmp += sum;
      ans = max(ans, tmp);
    } else {
      long long tmp = b12[i] + (sumb12[i] * t);
      tmp += a21[i] + (suma21[i] * (t + n - i + 1));
      tmp += sum;
      ans = max(ans, tmp);
    }
    if (i % 2 == 1) {
      sum += a[i] * t + b[i] * (t + 1);
    } else {
      sum += b[i] * t + a[i] * (t + 1);
    }
    t += 2;
  }
  cout << ans << endl;
  return 0;
}
