#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
long long n;
long long a[N + 3][2];
long long res;
long long s[N + 3][8];
int main() {
  scanf("%I64d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i][0]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i][1]);
  for (int i = 1; i <= n; i++) s[i][4] = s[i - 1][4] + a[i][0];
  for (int i = 1; i <= n; i++) s[i][0] = s[i - 1][0] + a[i][0] * (i - 1);
  for (int i = 1; i <= n; i++) s[i][6] = s[i - 1][6] + a[i][0] * (n - i);
  for (int i = 1; i <= n; i++) s[i][5] = s[i - 1][5] + a[i][1];
  for (int i = 1; i <= n; i++) s[i][7] = s[i - 1][7] + a[i][1] * (i - 1);
  for (int i = 1; i <= n; i++) s[i][1] = s[i - 1][1] + a[i][1] * (n - i);
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    if (i & 1) {
      s[i][2] = s[i - 1][2] + a[i][0] * ((i - 1) << 1);
      ans = s[i][2] + s[n][0] - s[i][0] + (i - 1) * (s[n][4] - s[i][4]) +
            s[n][1] - s[i - 1][1] + (n + i - 1) * (s[n][5] - s[i - 1][5]);
      res = max(res, ans);
      s[i][3] = s[i][2] + a[i][1] * ((i - 1) << 1 | 1);
      ans = s[i][3] + s[n][7] - s[i][7] + i * (s[n][5] - s[i][5]) + s[n][6] -
            s[i][6] + (i + n) * (s[n][4] - s[i][4]);
      res = max(res, ans);
    } else {
      s[i][3] = s[i - 1][3] + a[i][1] * ((i - 1) << 1);
      ans = s[i][3] + s[n][7] - s[i][7] + (i - 1) * (s[n][5] - s[i][5]) +
            s[n][6] - s[i - 1][6] + (n + i - 1) * (s[n][4] - s[i - 1][4]);
      res = max(res, ans);
      s[i][2] = s[i][3] + a[i][0] * ((i - 1) << 1 | 1);
      ans = s[i][2] + s[n][0] - s[i][0] + i * (s[n][4] - s[i][4]) + s[n][1] -
            s[i][1] + (long long)(i + n) * (s[n][5] - s[i][5]);
      res = max(res, ans);
    }
  }
  printf("%I64d", res);
  return 0;
}
