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 long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
string num2bit(long long num, long long len) {
  string bit = "";
  for (int i = 0; i < (int)len; ++i) {
    bit += char('0' + (num >> i & 1));
  }
  return bit;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<vector<long long>> x(2, vector<long long>(n, 0));
  for (int i = 0; i < (int)n; ++i) {
    cin >> x[0][i];
  }
  for (int i = 0; i < (int)n; ++i) {
    cin >> x[1][i];
  }
  vector<vector<long long>> S(2, vector<long long>(n + 1, 0));
  for (int i = 0; i < (int)2; ++i) {
    for (int j = 0; j < (int)n; ++j) {
      S[i][j + 1] = S[i][j] + x[i][j];
    }
  }
  vector<vector<long long>> LK(2, vector<long long>(n + 1, 0));
  vector<vector<long long>> RK(2, vector<long long>(n + 1, 0));
  for (int i = 0; i < (int)2; ++i) {
    for (int j = 0; j < (int)n; ++j) {
      LK[i][j + 1] = LK[i][j] + j * x[i][j];
      RK[i][j + 1] = RK[i][j] - j * x[i][j];
    }
  }
  long long geta = 0;
  long long ma = 0;
  for (int i = 0; i < (int)n; ++i) {
    long long tmp = 0;
    tmp += geta;
    if (i % 2 == 0) {
      tmp += i * (S[0][n] - S[0][i]);
      tmp += LK[0][n] - LK[0][i];
      tmp += (2 * n - 1 + i) * (S[1][n] - S[1][i]);
      tmp += RK[1][n] - RK[1][i];
    } else {
      tmp += (2 * n - 1 + i) * (S[0][n] - S[0][i]);
      ;
      tmp += RK[0][n] - RK[0][i];
      tmp += i * (S[1][n] - S[1][i]);
      tmp += LK[1][n] - LK[1][i];
    }
    chmax(ma, tmp);
    if (i % 2 == 0) {
      geta += 2 * i * x[0][i];
      geta += (2 * i + 1) * x[1][i];
    } else {
      geta += (2 * i + 1) * x[0][i];
      geta += 2 * i * x[1][i];
    }
  }
  cout << ma << endl;
  return 0;
}
