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;
inline long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
bool compare(pair<long long int, long long int> a,
             pair<long long int, long long int> b) {
  return a.second > b.second;
}
long long int n;
vector<vector<long long int> > A(2);
vector<long long int> dp11;
vector<long long int> dp12;
vector<long long int> dp21;
vector<long long int> dp22;
long long int cal11(long long int ind, long long int time) {
  long long int temp = (time - ind) * dp11[ind];
  temp += dp12[ind];
  return temp;
}
long long int cal21(long long int ind, long long int time) {
  long long int temp = (time - ind) * dp21[ind];
  temp += dp22[ind];
  return temp;
}
long long int cal12(long long int ind, long long int time) {
  long long int temp = (time + (n - 1)) * dp11[ind];
  temp -= dp12[ind];
  return temp;
}
long long int cal22(long long int ind, long long int time) {
  long long int temp = (time + (n - 1)) * dp21[ind];
  temp -= dp22[ind];
  return temp;
}
long long int dhoka(long long int a, long long int b, long long int time) {
  long long int temp = 0;
  if (a == 0) {
    temp += cal11(b, time);
    temp += cal22(b, time + n - b);
  } else {
    temp += cal21(b, time);
    temp += cal12(b, time + n - b);
  }
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  A[0].resize(n);
  A[1].resize(n);
  dp12.resize(n);
  dp11.resize(n);
  dp22.resize(n);
  dp21.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[0][i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> A[1][i];
  }
  dp11[n - 1] = A[0][n - 1];
  dp21[n - 1] = A[1][n - 1];
  dp12[n - 1] = (n - 1) * A[0][n - 1];
  dp22[n - 1] = (n - 1) * A[1][n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dp11[i] = dp11[i + 1] + A[0][i];
    dp21[i] = dp21[i + 1] + A[1][i];
    dp12[i] = dp12[i + 1] + i * A[0][i];
    dp22[i] = dp22[i + 1] + i * A[1][i];
  }
  long long int ans = 0;
  long long int current = 0;
  long long int time = 0;
  bool visited[2][n];
  memset(visited, 0, sizeof(bool) * 2 * n);
  bool down = true;
  for (int i = 0; i < n; ++i) {
    if (down) {
      ans = max(dhoka(0, i, time), ans);
      current += time * A[0][i];
      time++;
      current += time * A[1][i];
      time++;
    } else {
      ans = max(dhoka(1, i, time), ans);
      current += time * A[1][i];
      time++;
      current += time * A[0][i];
      time++;
    }
    down = !down;
  }
  ans = max(ans, current);
  cout << ans << endl;
  return 0;
}
