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;
#pragma GCC optimize("Ofast")
template <class T>
ostream &operator<<(ostream &s, vector<T> &P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T = int>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T = int>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T = int>
T powMod(T x, T k, T m) {
  if (k == 0) {
    return (T)1;
  }
  if (k % 2 == 0) {
    return powMod(x * x % m, k / 2, m);
  } else {
    return x * powMod(x, k - 1, m) % m;
  }
}
template <class T = int>
T extgcd(T a, T b, T &x, T &y) {
  T g = a;
  x = 1;
  y = 0;
  if (b != 0) {
    g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  }
  return g;
}
template <class T = int>
T invMod(T a, T m) {
  T x, y;
  if (extgcd(a, m, x, y) == 1) {
    return (x + m) % m;
  } else {
    return -1;
  }
}
using Pii = pair<int, int>;
using Pll = pair<long long, long long>;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<vector<long long>> a(2, vector<long long>(n));
  vector<long long> s(2 * n);
  vector<long long> s1(2 * n);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      if (i == 0) {
        s[j] = a[i][j];
        s1[2 * n - 1 - j] = a[i][j];
      } else {
        s[2 * n - 1 - j] = a[i][j];
        s1[j] = a[i][j];
      }
    }
  }
  for (int i = 1; i < 2 * n; i++) {
    s[i] += s[i - 1];
    s1[i] += s1[i - 1];
  }
  auto range_sum_s = [&](int l, int r) {
    if (l > 0) {
      return s[r] - s[l - 1];
    } else {
      return s[r];
    }
  };
  auto range_sum_s1 = [&](int l, int r) {
    if (l > 0) {
      return s1[r] - s1[l - 1];
    } else {
      return s1[r];
    }
  };
  long long ans = 0;
  long long tot_0 = 0, tot_1 = 0;
  for (int i = 1; i < 2 * n; i++) {
    tot_1 += range_sum_s(i, 2 * n - 1);
  }
  for (int i = 0; i < n; i += 2) {
    chmax(ans, tot_0 + tot_1);
    tot_0 += (2 * i) * range_sum_s(2 * i, 2 * i);
    tot_0 += (2 * i + 1) * range_sum_s(2 * n - 1 - 2 * i, 2 * n - 1 - 2 * i);
    tot_0 +=
        (2 * i + 2) * range_sum_s(2 * n - 1 - 2 * i - 1, 2 * n - 1 - 2 * i - 1);
    tot_0 += (2 * i + 3) * range_sum_s(2 * i + 1, 2 * i + 1);
    tot_1 -= (2 * i) * range_sum_s(2 * i, 2 * i);
    tot_1 -= (2 * i + 1) * range_sum_s(2 * i + 1, 2 * i + 1);
    tot_1 -=
        (2 * n - 1 - 2 * i) * range_sum_s(2 * n - 1 - 2 * i, 2 * n - 1 - 2 * i);
    tot_1 -= (2 * n - 1 - 2 * i - 1) *
             range_sum_s(2 * n - 1 - 2 * i - 1, 2 * n - 1 - 2 * i - 1);
    tot_1 += 2 * range_sum_s(2 * i + 2, 2 * n - 1 - 2 * i - 2);
  }
  tot_0 = 0;
  tot_1 = 0;
  tot_0 += 0 * s1[2 * n - 1];
  tot_0 += 1 * s1[0];
  for (int i = 1; i < 2 * n - 1; i++) {
    tot_1 += (i + 1) * range_sum_s1(i, i);
  }
  for (int i = 1; i < n; i += 2) {
    chmax(ans, tot_0 + tot_1);
    tot_0 += (2 * i) * range_sum_s1(2 * i - 1, 2 * i - 1);
    tot_0 += (2 * i + 1) *
             range_sum_s1(2 * n - 1 - 2 * i + 1, 2 * n - 1 - 2 * i + 1);
    tot_0 += (2 * i + 2) * range_sum_s1(2 * n - 1 - 2 * i, 2 * n - 1 - 2 * i);
    tot_0 += (2 * i + 3) * range_sum_s1(2 * i, 2 * i);
    tot_1 -= (2 * i) * range_sum_s1(2 * i - 1, 2 * i - 1);
    tot_1 -= (2 * i + 1) * range_sum_s1(2 * i, 2 * i);
    tot_1 -= (2 * n + 1 - 2 * i) * range_sum_s1(2 * n - 2 * i, 2 * n - 2 * i);
    tot_1 -=
        (2 * n - 2 * i) * range_sum_s1(2 * n - 2 * i - 1, 2 * n - 2 * i - 1);
    tot_1 += 2 * range_sum_s1(2 * i + 1, 2 * n - 2 - 2 * i);
  }
  cout << ans << '\n';
  return 0;
}
