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, a[3][300001], vis[3][300001];
long long ans;
int read(void) {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int x = c - '0';
  while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0';
  return x;
}
long long solve1(void) {
  int time = 0;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) sum += a[1][i] * time, time++;
  for (int i = n; i >= 1; --i) sum += a[2][i] * time, time++;
  return sum;
}
long long solve2(void) {
  int x = 1, y = 1, time = 0;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (x == 1) {
      sum += time * a[x][y];
      x++;
      time++;
      sum += time * a[x][y];
      y++;
      time++;
    } else {
      sum += time * a[x][y];
      x--;
      time++;
      sum += time * a[x][y];
      y++;
      time++;
    }
  }
  return sum;
}
long long solve3(void) {
  long long sum = 0;
  int time = 1;
  for (int i = 1; i <= n; ++i) sum += time * a[2][i], time++;
  for (int i = n; i > 1; --i) sum += time * a[1][i], time++;
  return sum;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[1][i] = read();
  for (int i = 1; i <= n; ++i) a[2][i] = read();
  ans = max(solve1(), solve2());
  ans = max(solve3(), ans);
  printf("%I64d", ans);
  return 0;
}
