#include <bits/stdc++.h>
using namespace std;
int N;
long long a[2][300000 + 5];
void solution1() {
  long long sum = 0, answer = 0;
  for (int i = 0; i < N; i++) {
    long long temp = sum, time = i * 2;
    if (i % 2 == 0) {
      for (int j = i; j < N; j++) {
        temp += time * a[0][j];
        time++;
      }
      for (int j = N - 1; j >= i; j--) {
        temp += time * a[1][j];
        time++;
      }
    } else {
      for (int j = i; j < N; j++) {
        temp += time * a[1][j];
        time++;
      }
      for (int j = N - 1; j >= i; j--) {
        temp += time * a[0][j];
        time++;
      }
    }
    answer = max(answer, temp);
    if (i % 2 == 0) {
      sum += a[0][i] * (i * 2);
      sum += a[1][i] * (i * 2 + 1);
    } else {
      sum += a[1][i] * (i * 2);
      sum += a[0][i] * (i * 2 + 1);
    }
  }
  cout << answer << endl;
}
void solution2() {
  long long answer = 0, time = 0, temp = 0;
  for (int i = 0; i < N; i++) {
    temp += time * a[0][i];
    time++;
  }
  for (int i = N - 1; i >= 0; i--) {
    temp += time * a[1][i];
    time++;
  }
  answer = temp;
  temp = 0, time = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      temp += time * a[0][i];
      time++;
      temp += time * a[1][i];
      time++;
    } else {
      temp += time * a[1][i];
      time++;
      temp += time * a[0][i];
      time++;
    }
  }
  answer = max(answer, temp);
  cout << answer << endl;
}
void solution3() {
  long long answer = 0, time = 0, temp = 0, clockRoute = 0,
            meanderrRouteSum = 0, clockRouteSum = 0;
  for (int i = 0; i < N; i++) {
    clockRouteSum += time * a[0][i];
    time++;
  }
  for (int i = N - 1; i >= 0; i--) {
    clockRouteSum += time * a[1][i];
    time++;
  }
  time = 0;
  for (int i = 0; i < N; i++) clockRoute += (a[0][i] + a[1][i]);
  for (int i = 0; i < N; i += 2) {
    temp = meanderrRouteSum + clockRouteSum;
    answer = max(answer, temp);
    meanderrRouteSum += time * a[0][i];
    clockRouteSum -= time * a[0][i];
    time++;
    meanderrRouteSum += time * a[1][i];
    clockRouteSum -= time * a[0][i + 1];
    time++;
    meanderrRouteSum += time * a[1][i + 1];
    time++;
    meanderrRouteSum += time * a[0][i + 1];
    time++;
    clockRouteSum -= a[1][i] * (2 * N - 1);
    clockRouteSum -= a[1][i + 1] * (2 * N - 2);
    clockRoute -= (a[0][i] + a[0][i + 1] + a[1][i] + a[1][i + 1]);
    clockRouteSum += clockRoute * 2;
  }
  time = 2, temp = 0, clockRoute = 0, clockRouteSum = 0;
  meanderrRouteSum = 1 * a[1][0];
  for (int i = 1; i < N; i++) {
    clockRouteSum += time * a[1][i];
    time++;
  }
  for (int i = N - 1; i >= 1; i--) {
    clockRouteSum += time * a[0][i];
    time++;
  }
  for (int i = 1; i < N; i++) clockRoute += (a[0][i] + a[1][i]);
  time = 2;
  for (int i = 1; i < N; i += 2) {
    temp = clockRouteSum + meanderrRouteSum;
    answer = max(answer, temp);
    meanderrRouteSum += time * a[1][i];
    clockRouteSum -= time * a[1][i];
    time++;
    meanderrRouteSum += time * a[0][i];
    clockRouteSum -= time * a[1][i + 1];
    time++;
    meanderrRouteSum += time * a[0][i + 1];
    time++;
    meanderrRouteSum += time * a[1][i + 1];
    time++;
    clockRouteSum -= a[0][i] * (2 * N - 1);
    clockRouteSum -= a[0][i + 1] * (2 * N - 2);
    clockRoute -= (a[0][i] + a[0][i + 1] + a[1][i] + a[1][i + 1]);
    clockRouteSum += clockRoute * 2;
  }
  cout << answer << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[0][i];
  for (int i = 0; i < N; i++) cin >> a[1][i];
  solution3();
  return 0;
}
