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 n;
long long a[300005], b[300005], suma[300005][3], sumb[300005][3], ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (int i = n; i >= 1; i--) {
    suma[i][0] = suma[i + 1][0] + a[i];
    sumb[i][0] = sumb[i + 1][0] + b[i];
  }
  long long sum = 0;
  for (int i = n; i >= 1; i--) {
    suma[i][1] = suma[i + 1][1] + sum;
    sum += a[i];
  }
  sum = 0;
  for (int i = n; i >= 1; i--) {
    sumb[i][1] = sumb[i + 1][1] + sum;
    sum += b[i];
  }
  for (int i = n; i >= 1; i--) {
    suma[i][2] = suma[i + 1][2] + 1ll * (n - i) * a[i];
    sumb[i][2] = sumb[i + 1][2] + 1ll * (n - i) * b[i];
  }
  sum = 0;
  long long now = 0;
  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      ans = max(ans, sum + suma[i][1] + sumb[i][2] + now * suma[i][0] +
                         (now + n - i + 1) * sumb[i][0]);
      sum += now * a[i];
      now++;
      ans = max(ans, sum + sumb[i][1] + suma[i + 1][2] + now * sumb[i][0] +
                         (now + n - i + 1) * suma[i + 1][0]);
      sum += now * b[i];
      now++;
    } else {
      ans = max(ans, sum + sumb[i][1] + suma[i][2] + now * sumb[i][0] +
                         (now + n - i + 1) * suma[i][0]);
      sum += now * b[i];
      now++;
      ans = max(ans, sum + suma[i][1] + sumb[i + 1][2] + now * suma[i][0] +
                         (now + n - i + 1) * sumb[i + 1][0]);
      sum += now * a[i];
      now++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
