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 main() {
  int n;
  cin >> n;
  vector<vector<int> > glade;
  for (int i = 0; i < 2; i++) {
    vector<int> gladei;
    for (int j = 0; j < n; j++) {
      int num;
      cin >> num;
      gladei.push_back(num);
    }
    glade.push_back(gladei);
  }
  vector<int> sum(n);
  sum[n - 1] = glade[0][n - 1] + glade[1][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    sum[i] = sum[i + 1] + glade[0][i] + glade[1][i];
  }
  vector<int> anticlock(n);
  vector<int> clockwise(n);
  anticlock[n - 1] =
      (2 * n - 1) * glade[0][n - 1] + 2 * (n - 1) * glade[1][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    anticlock[i] = anticlock[i + 1] - sum[i + 1] + (2 * n - 1) * glade[0][i] +
                   2 * (i)*glade[1][i];
  }
  clockwise[n - 1] =
      (2 * (n - 1)) * glade[0][n - 1] + (2 * n - 1) * glade[1][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    clockwise[i] = clockwise[i + 1] - sum[i + 1] + (2 * n - 1) * glade[1][i] +
                   2 * (i)*glade[0][i];
  }
  long maxval = INT_MIN;
  bool top = true;
  long path = 0;
  for (int i = 0; i < n; i++) {
    if (top) {
      maxval = max(maxval, clockwise[i] + path);
      path += glade[0][i] * (2 * i) + glade[1][i] * (2 * i + 1);
      top = false;
    } else {
      maxval = max(maxval, anticlock[i] + path);
      path += glade[1][i] * (2 * i) + glade[0][i] * (2 * i + 1);
      top = true;
    }
  }
  maxval = max(maxval, path);
  cout << maxval << endl;
  return 0;
}
