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>
#pragma GCC optimize(3)
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar(' ');
}
int n;
int a[2][300005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  long long ans = 0;
  int now = 0;
  for (int i = 1; i <= n; i++) ans += (long long)(now++) * a[0][i];
  for (int i = n; i >= 1; i--) ans += (long long)(now++) * a[1][i];
  long long ans1 = 0;
  now = 0;
  int nowx = 0, nowy = 1;
  for (int i = 1; i <= n * 2; i++) {
    ans1 += (long long)(i - 1) * a[nowx][nowy];
    if (nowx) {
      nowx--;
      nowy++;
    } else
      nowx++;
  }
  printf("%lld\n", max(ans1, ans));
  return 0;
}
