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 = 300005;
int n;
long long a[2][maxn];
long long DP[2][maxn];
long long hna[maxn];
long long hna2[maxn];
long long dp(bool j, int i) {
  if (i >= n) return 0;
  long long &ret = DP[j][i];
  if (~ret) return ret;
  ret = 0;
  if (j) {
    long long tmp = (((i * 2)) * a[1][i]) + (((i * 2) + 1) * a[0][i]);
    ret = max(ret, dp(0, i + 1) + tmp);
    ret = max(ret, dp(0, n) + hna2[i]);
  } else {
    long long tmp = (((i * 2)) * a[0][i]) + (((i * 2) + 1) * a[1][i]);
    ret = max(ret, dp(1, i + 1) + tmp);
    ret = max(ret, dp(0, n) + hna[i]);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j) cin >> a[i][j], sum += a[i][j];
  long long m3lsh = 0, cnt = 0;
  long long tot = (n * 2) - 1;
  for (int i = 0; i < n; ++i, ++cnt) m3lsh += (a[0][i] * cnt);
  for (int i = n - 1; i >= 0; --i, ++cnt) m3lsh += (a[1][i] * cnt);
  for (int i = 0; i < n - 1; i += 2) {
    hna[i] = m3lsh;
    sum -= a[0][i];
    sum -= a[1][i];
    sum -= a[1][i + 1];
    sum -= a[0][i + 1];
    m3lsh -= sum;
    m3lsh -= (tot * a[1][i]);
    m3lsh -= ((tot - 1) * a[1][i + 1]);
    m3lsh -= (i * a[0][i]);
    m3lsh -= ((i + 1) * a[0][i + 1]);
    tot -= 2;
    m3lsh += (i * sum);
  }
  m3lsh = 0;
  cnt = 2;
  tot = (n * 2) - 1;
  for (int i = 1; i < n; ++i, ++cnt) m3lsh += (a[1][i] * cnt);
  for (int i = n - 1; i > 0; --i, ++cnt) m3lsh += (a[0][i] * cnt);
  for (int i = 1; i < n; i += 2) {
    hna2[i] = m3lsh;
    sum -= a[0][i];
    sum -= a[1][i];
    sum -= a[1][i + 1];
    sum -= a[0][i + 1];
    m3lsh -= sum;
    m3lsh -= (tot * a[0][i]);
    m3lsh -= ((tot - 1) * a[0][i + 1]);
    m3lsh -= ((i - 1) * a[1][i]);
    m3lsh -= (i * a[1][i + 1]);
    tot -= 2;
    m3lsh += (i * sum);
  }
  memset(DP, -1, sizeof DP);
  cout << dp(0, 0) << endl;
  return 0;
}
