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;
int a[300005], b[300005];
int sum[300005], suma[300005], sumb[300005], sumc[300005];
long long int n, m, i, j, ans = 0;
void pre() {
  sum[n + 1] = 0;
  suma[n + 1] = 0;
  sumb[n + 1] = 0;
  sumc[n + 1] = 0;
  for (i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i] + b[i];
  for (i = n, j = n; i >= 1; i--, j++)
    suma[i] = suma[i + 1] + a[i] * (i - 1) + b[i] * j;
  for (i = n, j = n + 1; i >= 2; i--, j++)
    sumb[i] = sumb[i + 1] + a[i] * (j) + b[i] * (i);
  sumb[1] = sumb[2] + b[1];
  long long int c = 0, ret = 0;
  for (i = 1; i <= n; i++) {
    if (i % 2 == 0) {
      ret += c * b[i];
      c++;
      ret += c * a[i];
      c++;
      sumc[i] = ret;
    } else {
      ret += c * a[i];
      c++;
      ret += c * b[i];
      c++;
      sumc[i] = ret;
    }
  }
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  pre();
  for (i = 0; i <= n; i++) {
    if (i % 2 == 0)
      ans = max(ans, sumc[i] + suma[i + 1] + i * sum[i + 1]);
    else
      ans = max(ans, sumc[i] + sumb[i + 1] + (i - 1) * sum[i + 1]);
  }
  cout << ans << endl;
}
