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 setIO(string str, bool dbg) {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (!dbg) {
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
  }
}
const int MAX = 3e5 + 5;
const int LEN = 2e3 + 5;
const int LVL = 2e1 + 0;
const long long int MOD = 1e9 + 7;
const long long int INF = 2e9;
int xyz = 1;
int n;
long long int sum[MAX];
long long int dps[MAX];
int arr[MAX][2];
long long int crc[MAX][2];
long long int getCircle(int pos, int side, int time) {
  return pos > n ? 0 : crc[pos][side] + sum[pos] * time;
}
void setCircle(int side) {
  for (int i = n; i >= 1; i--) {
    crc[i][side] += sum[i + 1];
    crc[i][side] += crc[i + 1][side];
    crc[i][side] += arr[i][1 ^ side] * ((n - i) * 2 + 1);
  }
}
void fnc() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i][0];
  for (int i = 1; i <= n; i++) cin >> arr[i][1];
  for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + arr[i][0] + arr[i][1];
  setCircle(0);
  setCircle(1);
  long long int cur = 1;
  long long int ans = getCircle(1, 0, 0);
  dps[1] = arr[1][1];
  for (int i = 2; i <= n; i++) {
    int par = i % 2;
    dps[i] = dps[i - 1] + arr[i][1 ^ par] * (cur + 1) + arr[i][par] * (cur + 2);
    cur += 2;
  }
  for (int i = 1; i <= n; i++)
    ans = max(ans, dps[i] + getCircle(i + 1, i % 2, i * 2));
  cout << ans << "\n";
}
int main() {
  setIO("", 1);
  while (xyz--) fnc();
  return 0;
}
