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 INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int MAXN = 3e5 + 5;
const int MAXM = 2e6 + 5;
const int MOD = 1e9 + 7;
int sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
long long pw(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int n, a[2][MAXN];
bool vis[2][MAXN];
int mx;
pair<int, int> pos;
long long ans;
int lx, ly, t;
void dfs(int x, int y) {
  if (y >= ly) return;
  ans += 1ll * t * a[x][y];
  vis[x][y] = true;
  t++;
  if (!x) {
    if (!vis[x + 1][y])
      dfs(x + 1, y);
    else
      dfs(x, y + 1);
  } else {
    if (!vis[x - 1][y])
      dfs(x - 1, y);
    else
      dfs(x, y + 1);
  }
}
int main() {
  scanf("%d", &n);
  mx = -1;
  for (int j = 0; j < 2; j++) {
    for (int i = 1; i < n + 1; i++) {
      scanf("%d", &a[j][i]);
      if (mx < a[j][i]) {
        if (j == 0 && i == 1) continue;
        mx = a[j][i];
        pos = make_pair(j, i);
      }
    }
  }
  memset(vis, false, sizeof(vis));
  ans = 0;
  if (((pos.first + pos.second) % 2 == 1) && pos.second != 1) {
    vis[pos.first][pos.second - 1] = true, ans += 1ll * (2 * n - 1) *
                                                  a[pos.first][pos.second - 1];
    vis[pos.first][pos.second] = true,
    ans += 1ll * (2 * n - 2) * a[pos.first][pos.second];
    lx = pos.first ^ 1;
    ly = pos.second - 1;
  } else {
    vis[pos.first][pos.second] = true,
    ans += 1ll * (2 * n - 1) * a[pos.first][pos.second];
    lx = pos.first ^ 1;
    ly = pos.second;
  }
  t = 0;
  dfs(0, 1);
  for (int i = ly; i < n + 1; i++) {
    ans += 1ll * t * a[lx][i], t++;
  }
  lx ^= 1;
  for (int i = n + 1 - 1; i >= ly; i--) {
    if (!vis[lx][i]) ans += 1ll * t * a[lx][i], t++;
  }
  printf("%lld\n", ans);
}
