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;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
int N, C[300005][2];
ll S[600005], T[600005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  cin >> N;
  for (int(i) = (0); (i) < (int)(N); ++(i)) cin >> C[i][0];
  for (int(i) = (0); (i) < (int)(N); ++(i)) cin >> C[i][1];
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    S[i + 1] = S[i] + (ll)C[i][0] * i;
    T[i + 1] = T[i] + C[i][0];
  }
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    S[N + i + 1] = S[N + i] + (ll)C[N - 1 - i][1] * (N + i);
    T[N + i + 1] = T[N + i] + C[N - 1 - i][1];
  }
  ll re = 0;
  ll sm = 0;
  int y = 0, x = 0;
  for (int(i) = (0); (i) < (int)(2 * N); ++(i)) {
    if (y == 0) {
      int rem = 2 * N - i;
      int j = i / 2;
      ll z = S[j + rem] - S[j] + (T[j + rem] - T[j]) * (i - j);
      ll val = sm + z;
      (re) = max((re), (val));
    }
    sm += (ll)C[x][y] * i;
    if (i % 4 == 0)
      y = 1;
    else if (i % 4 == 2)
      y = 0;
    else
      x++;
  }
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    S[i + 1] = S[i] + (ll)C[i][1] * i;
    T[i + 1] = T[i] + C[i][1];
  }
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    S[N + i + 1] = S[N + i] + (ll)C[N - 1 - i][0] * (N + i);
    T[N + i + 1] = T[N + i] + C[N - 1 - i][0];
  }
  sm = 0;
  y = 0, x = 0;
  for (int(i) = (0); (i) < (int)(2 * N); ++(i)) {
    if (y == 1) {
      int rem = 2 * N - i;
      int j = i / 2;
      ll z = S[j + rem] - S[j] + (T[j + rem] - T[j]) * (i - j);
      ll val = sm + z;
      (re) = max((re), (val));
    }
    sm += (ll)C[x][y] * i;
    if (i % 4 == 0)
      y = 1;
    else if (i % 4 == 2)
      y = 0;
    else
      x++;
  }
  cout << re << endl;
}
