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 aa[600005];
int bb[300005];
long long kuai[600005];
long long ji[600005];
long long fji[600005];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> aa[i];
  for (int i = 1; i <= n; i++) cin >> bb[i];
  for (int i = n + 1, j = n; i <= 2 * n, j >= 1; i++, j--) {
    aa[i] = bb[j];
  }
  for (int i = 1; i <= 2 * n; i++) kuai[i] = kuai[i - 1] + (long long)aa[i];
  for (int i = 1; i <= 2 * n; i++) ji[i] = ji[i - 1] + (long long)i * aa[i];
  for (int i = 2 * n, j = 1; i >= 1, j <= 2 * n; i--, j++)
    fji[j] = fji[j - 1] + (long long)j * aa[i];
  long long res = 0;
  long long tres = 0;
  long long temp = 0;
  long long tt = 0;
  for (long long i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      if (i != 1) {
        temp += tt * bb[i - 1];
        tt++;
        temp += tt * aa[i - 1];
        tt++;
      }
      tres = temp + ji[2 * n - i + 1] - ji[i - 1] +
             (tt - i) * (kuai[2 * n - i + 1] - kuai[i - 1]);
      res = max(res, tres);
    } else {
      temp += tt * aa[i - 1];
      tt++;
      temp += tt * bb[i - 1];
      tt++;
      tres = temp + fji[2 * n - i + 1] - fji[i - 1] +
             (tt - i) * (kuai[2 * n - i + 1] - kuai[i - 1]);
      res = max(res, tres);
    }
  }
  cout << res;
  return 0;
}
