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;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long N;
  cin >> N;
  long long a[N][2];
  for (long long j = 0; j < 2; j++) {
    for (long long i = 0; i < N; i++) {
      cin >> a[i][j];
    }
  }
  long long t = 0, sum = 0, ans;
  for (long long i = 0; i < N; i++) {
    sum += t * a[i][0];
    t++;
  }
  for (long long i = N - 1; i >= 0; i--) {
    sum += t * a[i][1];
    t++;
  }
  ans = sum;
  t = 0, sum = 0;
  for (long long i = 0; i < N; i++) {
    if (i % 2 == 0) {
      sum += a[i][0] * t;
      t++;
      sum += a[i][1] * t;
      t++;
    } else {
      sum += a[i][1] * t;
      t++;
      sum += a[i][0] * t;
      t++;
    }
  }
  ans = max(ans, sum);
  cout << ans << "\n";
  return 0;
}
