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;
void printv(vector<long long>& a) {
  cerr << "v:\n";
  for (auto aa : a) cerr << aa << " ";
  cerr << endl;
}
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) cin >> b[i];
  vector<long long> topf(n), top(n), topb(n);
  vector<long long> bot(n), botb(n), botf(n);
  top[n - 1] = a[n - 1];
  bot[n - 1] = b[n - 1];
  for (long long i = n - 2; i >= 0; --i) {
    top[i] = top[i + 1] + a[i];
    bot[i] = bot[i + 1] + b[i];
    topf[i] = topf[i + 1] + top[i + 1];
    botb[i] = botb[i + 1] + b[i] * (n - i - 1);
    topb[i] = topb[i + 1] + a[i] * (n - i - 1);
    botf[i] = botf[i + 1] + bot[i + 1];
  }
  long long ans = 0, cur = 0;
  for (long long spot = 0; spot < n; spot += 2) {
    long long cand = topf[spot] + botb[spot] + (n - spot) * bot[spot];
    cand = cur + cand + (spot * 2) * (top[spot] + bot[spot]);
    ans = max(ans, cand);
    cur += a[spot] * (spot * 2) + b[spot] * (spot * 2 + 1) +
           b[spot + 1] * (spot * 2 + 2) + a[spot + 1] * (spot * 2 + 3);
  }
  cur = b[0];
  for (long long spot = 1; spot < n; spot += 2) {
    long long cand = botf[spot] + topb[spot] + (n - spot) * top[spot];
    cand = cur + cand + (spot * 2) * (bot[spot] + top[spot]);
    ans = max(ans, cand);
    cur += b[spot] * (spot * 2) + a[spot] * (spot * 2 + 1) +
           a[spot + 1] * (spot * 2 + 2) + b[spot + 1] * (spot * 2 + 3);
  }
  cout << ans << endl;
  return 0;
}
