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;
const int MAXN = 3 * 100000 + 10;
int n;
int row[3][MAXN];
unsigned long long ans;
unsigned long long tans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2; i++)
    for (int j = 0; j < n; j++) scanf("%d", &row[i][j]);
  unsigned long long ti = 0;
  for (int i = 0; i < n; i++) {
    tans += ti * row[1][i];
    ti++;
  }
  for (int i = n - 1; i >= 0; i--) {
    tans += ti * row[2][i];
    ti++;
  }
  ans = max(ans, tans);
  tans = 0;
  ti = 1;
  for (int i = 0; i < n; i++) {
    tans += ti * row[2][i];
    ti++;
  }
  for (int i = n - 1; i > 0; i--) {
    tans += ti * row[1][i];
    ti++;
  }
  ans = max(ans, tans);
  tans = 0;
  ti = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2) {
      tans += ti * row[2][i];
      ti++;
      tans += ti * row[1][i];
      ti++;
    } else {
      tans += ti * row[1][i];
      ti++;
      tans += ti * row[2][i];
      ti++;
    }
  }
  ans = max(ans, tans);
  tans = 0;
  ti = 0;
  cout << ans << endl;
  return 0;
}
