#include <bits/stdc++.h>
using namespace std;
namespace Debug {
void __print(signed x) { cout << x; }
void __print(long x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(unsigned x) { cout << x; }
void __print(unsigned long x) { cout << x; }
void __print(unsigned long long x) { cout << x; }
void __print(float x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char *x) { cout << '\"' << x << '\"'; }
void __print(const string &x) { cout << '\"' << x << '\"'; }
void __print(bool x) { cout << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "]" << endl; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
}  // namespace Debug
using namespace Debug;
template <typename Arg1>
void p(Arg1 &&arg1) {
  cout << arg1;
}
template <typename Arg1, typename... Args>
void p(Arg1 &&arg1, Args &&...args) {
  cout << arg1;
  p(args...);
}
template <typename Arg1>
void read(Arg1 &&arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1 &&arg1, Args &&...args) {
  cin >> arg1;
  read(args...);
}
const bool DEBUG = true;
void process() {
  long long n, res = 0ll;
  read(n);
  long long a[n + 1], b[n + 1];
  a[0] = 0;
  b[0] = 0;
  for (long long i = 1; i <= n; i++) read(a[i]);
  for (long long i = 1; i <= n; i++) read(b[i]);
  long long aLR[n + 2], aRL[n + 2], aPref[n + 2], bLR[n + 2], bRL[n + 2],
      bPref[n + 2];
  memset((aLR), (0), sizeof((aLR)));
  memset((aRL), (0), sizeof((aRL)));
  memset((aPref), (0), sizeof((aPref)));
  memset((bLR), (0), sizeof((bLR)));
  memset((bRL), (0), sizeof((bRL)));
  memset((bPref), (0), sizeof((bPref)));
  for (long long i = 1; i <= n; i++) aLR[i] = aLR[i - 1] + (a[i] * (i - 1));
  for (long long i = n; i >= 1; i--) aRL[i] = aRL[i + 1] + (a[i] * (n - i));
  for (long long i = 1; i <= n; i++) aPref[i] = a[i] + aPref[i - 1];
  for (long long i = 1; i <= n; i++) bLR[i] = bLR[i - 1] + (b[i] * (i - 1));
  for (long long i = n; i >= 1; i--) bRL[i] = bRL[i + 1] + (b[i] * (n - i));
  for (long long i = 1; i <= n; i++) bPref[i] = b[i] + bPref[i - 1];
  long long r = 1, c = 1, sum = 0ll, collected = 0ll, moveRight = 0,
            extraSteps = 0;
  for (long long i = 1, moved = 1; i <= n; i++) {
    if (r == 1) {
      extraSteps = moved - c;
      collected =
          sum + (aLR[n] - aLR[c - 1]) + (aPref[n] - aPref[c - 1]) * extraSteps;
      extraSteps = moved + (n - c);
      collected += bRL[c] + (bPref[n] - bPref[c - 1]) * extraSteps;
      res = max(res, collected);
      sum += (a[c] * (moved - 1)) + (b[c] * moved);
      moved += 2;
    } else {
      extraSteps = moved - c;
      collected =
          sum + (bLR[n] - bLR[c - 1]) + (bPref[n] - bPref[c - 1]) * extraSteps;
      extraSteps = moved + (n - c);
      collected += aRL[c] + (aPref[n] - aPref[c - 1]) * extraSteps;
      res = max(res, collected);
      sum += (b[c] * (moved - 1)) + (a[c] * moved);
      moved += 2;
    }
    ++c;
    r = (r == 1) ? 2 : 1;
  }
  cout << res << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    process();
  }
  return 0;
}
