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 INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 3e5 + 10;
const int MAXM = 2e6 + 10;
const long long mod = 1e9 + 7;
long long a[MAXN], b[MAXN];
long long suma[MAXN], sumb[MAXN];
long long prea[MAXN], preb[MAXN];
long long sufa[MAXN], sufb[MAXN];
int dx[4] = {1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset((suma), (0), sizeof(suma));
  memset((sumb), (0), sizeof(sumb));
  memset((prea), (0), sizeof(prea));
  memset((preb), (0), sizeof(preb));
  memset((sufa), (0), sizeof(sufa));
  memset((sufb), (0), sizeof(sufb));
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    suma[i] = suma[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    sumb[i] = sumb[i - 1] + b[i];
  }
  long long ans = 0, ans1 = 0, ans2 = 0;
  long long now = 0;
  for (int i = 1; i <= n; i++) ans1 += now * a[i], now++, prea[i] = ans1;
  sufa[n + 1] = ans1;
  for (int i = n; i >= 1; i--) ans1 += now * b[i], now++, sufa[i] = ans1;
  now = 0;
  for (int i = 1; i <= n; i++) ans2 += now * b[i], now++, preb[i] = ans2;
  sufb[n + 1] = ans2;
  for (int i = n; i >= 1; i--) ans2 += now * a[i], now++, sufb[i] = ans2;
  ans = max(ans1, ans2);
  int pos = 0, x = 1;
  long long cnt = b[1];
  now = 2;
  while (now < 2ll * n) {
    if (pos == 0) {
      ans = max(ans, cnt + preb[n] - preb[x] + sufb[x + 1] - sufb[n + 1] +
                         (long long)(x - 1) *
                             ((sumb[n] - sumb[x]) + (suma[n] - suma[x])));
      cnt += now * b[x + 1];
      x++;
      now++;
    } else if (pos == 1) {
      cnt += now * a[x];
      now++;
    } else if (pos == 2) {
      ans = max(ans, cnt + prea[n] - prea[x] + sufa[x + 1] - sufa[n + 1] +
                         (long long)(x - 1) *
                             ((suma[n] - suma[x]) + (sumb[n] - sumb[x])));
      cnt += now * a[x + 1];
      x++;
      now++;
    } else if (pos == 3) {
      cnt += now * b[x];
      now++;
    }
    pos = (pos + 1) % 4;
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}
