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;
class Timer {
  clock_t start;
  string name;

 public:
  Timer() {
    name = "";
    start = clock();
  }
  Timer(string s) {
    name = s;
    start = clock();
  }
  ~Timer() {
    fprintf(stderr, "%s: %.3gs\n", name.c_str(),
            1.0 * (clock() - start) / CLOCKS_PER_SEC);
  }
};
const double EPS = 1e-9;
const int INF = 0x7fffffff;
const double PI = acos(-1.0);
const int MAX = 300005;
const int MOD = 1000000007;
const int precision = 10;
inline bool isEq(double a, double b) { return abs(a - b) < EPS; }
inline bool isEq(double a, double b, double eps) { return abs(a - b) < eps; }
inline double toRad(double deg) { return deg * PI / 180; }
inline double toDeg(double rad) { return rad * 180 / PI; }
int dr[] = {1, 0, -1};
int dc[] = {0, 1, 0};
long long grid[2][MAX], linfor[2 * MAX], linbac[2 * MAX], linfor2[2 * MAX],
    linbac2[2 * MAX];
long long calFor(int st, int en, int p) {
  long long sum = linfor[en];
  if (st) sum -= linfor[st - 1];
  sum *= (p - st);
  sum += linfor2[en];
  if (st) sum -= linfor2[st - 1];
  return sum;
}
long long calBac(int st, int en, int p) {
  long long sum = linbac[en];
  if (st) sum -= linbac[st - 1];
  sum *= (p - st);
  sum += linbac2[en];
  if (st) sum -= linbac2[st - 1];
  return sum;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> grid[i][j];
      linfor[i * n + j] = grid[i][j];
    }
  }
  reverse(linfor + n, linfor + 2 * n);
  for (int i = 0; i < 2 * n; i++) {
    linbac[2 * n - i - 1] = linfor[i];
  }
  for (int i = 1; i < 2 * n; i++) {
    linfor2[i] = linfor2[i - 1] + linfor[i] * i;
    linbac2[i] = linbac2[i - 1] + linbac[i] * i;
    linfor[i] += linfor[i - 1];
    linbac[i] += linbac[i - 1];
  }
  long long mx = 0, curr = 0;
  int tm = -1, d = 0;
  int inc1 = 1;
  for (int r = 0, c = 0; c < n;) {
    tm++;
    mx = max(mx, curr + calFor(c, 2 * n - c - 1, tm));
    curr += tm * grid[r][c];
    r++;
    tm++;
    curr += tm * grid[r][c];
    if (c + 1 >= n) break;
    mx = max(mx, curr + calBac(c + 1, 2 * n - 1 - c - 1, tm + 1));
    c++;
    tm++;
    curr += tm * grid[r][c];
    r--;
    tm++;
    curr += tm * grid[r][c];
    c++;
  }
  cout << max(curr, mx);
  return 0;
}
