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 long long MOD = (long long)1e9 + 7;
const int inf = (int)1e9 + 7;
const double eps = 1e-7;
const double pi = 3.14159265359;
const int N = 3e5;
int n, a[N][2];
long long pref[N][2], sum_time[N][2], rev_sum_time[N][2], ans;
int main() {
  scanf("%d", &n);
  for (int k = 0; k < 2; ++k) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i][k]);
      pref[i][k] = a[i][k] + (i ? pref[i - 1][k] : 0);
      sum_time[i][k] = (long long)a[i][k] * i + (i ? sum_time[i - 1][k] : 0);
    }
  }
  for (int k = 0; k < 2; ++k) {
    for (int i = n - 1; i >= 0; --i)
      rev_sum_time[i][k] = (long long)a[i][k] * (n - i - 1) +
                           (i != n - 1 ? rev_sum_time[i + 1][k] : 0);
  }
  long long cur_sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int k1 = 0; k1 < 2; ++k1) {
      long long cur_time = i * 2 + k1;
      long long k = (i & 1 ? 1 - k1 : k1);
      cur_sum += cur_time * a[i][k];
      if (cur_time & 1) continue;
      long long sumh = sum_time[n - 1][k] - sum_time[i][k];
      sumh += (pref[n - 1][k] - pref[i][k]) * (cur_time - i);
      cur_time += n - i;
      sumh += rev_sum_time[i][1 - k];
      sumh += (pref[n - 1][1 - k] - (i ? pref[i - 1][1 - k] : 0)) * cur_time;
      ans = max(ans, cur_sum + sumh);
    }
  }
  ans = max(ans, cur_sum);
  printf("%lld", ans);
  return 0;
}
