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 N = 300005;
int n;
long long a[2][N], ans;
long long tmp[2][N], Tmp;
long long tmp2[2][N], Tmp2;
long long sum[N];
void prepare() {
  for (int i = 1; i <= n; i++) {
    tmp[0][i] = a[0][i] * (i - 1);
    tmp2[1][i] = a[1][i] * (i - 1);
  }
  for (int i = n; i >= 1; i--) {
    tmp[1][i] = a[1][i] * (2 * n - i);
    tmp2[0][i] = a[0][i] * (2 * n - i);
  }
  for (int i = 1; i <= n; i++) {
    tmp[0][i] += tmp[0][i - 1];
    tmp[1][i] += tmp[1][i - 1];
    tmp2[0][i] += tmp2[0][i - 1];
    tmp2[1][i] += tmp2[1][i - 1];
  }
  Tmp = tmp[0][n] + tmp[1][n];
  Tmp2 = tmp2[0][n] + tmp2[1][n];
  for (int i = n; i >= 1; i--) sum[i] = a[0][i] + a[1][i] + sum[i + 1];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[0][i];
  for (int i = 1; i <= n; i++) cin >> a[1][i];
  prepare();
  long long t = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2) {
      ans =
          max(ans, t + Tmp - tmp[0][i - 1] - tmp[1][i - 1] + (i - 1) * sum[i]);
      t += (2 * i - 2) * a[0][i] + (2 * i - 1) * a[1][i];
    } else {
      ans = max(ans,
                t + Tmp2 - tmp2[1][i - 1] - tmp2[0][i - 1] + (i - 1) * sum[i]);
      t += (2 * i - 2) * a[1][i] + (2 * i - 1) * a[0][i];
    }
  }
  ans = max(ans, t);
  cout << ans << endl;
  return 0;
}
