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;
void READ() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(8);
}
const int N = 5 + 3e5;
int n, m;
long long sum[N], sum2[N], a[N], b[N], sa1[N], sa2[N], sb1[N], sb2[N], ans;
int main() {
  READ();
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      sum[i] = sum[i - 1] + a[i] * (2 * i - 2) + b[i] * (2 * i - 1);
    else
      sum[i] = sum[i - 1] + b[i] * (2 * i - 2) + a[i] * (2 * i - 1);
  }
  for (int i = n; i >= 1; i--) {
    sum2[i] = sum2[i + 1] + a[i] + b[i];
    sa1[i] = sa1[i + 1] + (i - 1) * a[i];
    sa2[i] = sa2[i + 1] + (2 * n - i) * a[i];
    sb1[i] = sb1[i + 1] + (i - 1) * b[i];
    sb2[i] = sb2[i + 1] + (2 * n - i) * b[i];
  }
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      ans = max(ans, sum[i - 1] + sa1[i] + sb2[i] + (i - 1) * sum2[i]);
    else {
      ans = max(ans, sum[i - 1] + sa2[i] + sb1[i] + (i - 1) * sum2[i]);
    }
  }
  cout << ans;
  return 0;
}
