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;
long long mx, n, a[3][300005], b1[3][300005], b2[3][300005], sum1[3][300005],
    sum2[3][300005], r;
void calc() {
  long long times1 = 0;
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= n; j++) {
      sum1[i][j] = a[i][j];
      sum1[i][j] += sum1[i][j - 1];
    }
    for (int j = n; j >= 1; j--) {
      sum2[i][j] = a[i][j];
      sum2[i][j] += sum2[i][j + 1];
    }
  }
  for (int j = 1; j <= 2; j++) {
    for (int i = n; i >= 1; i--) {
      b1[j][i] = sum1[j][n] - sum1[j][i - 1];
      b1[j][i] += b1[j][i + 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 2; j >= 1; j--) {
      b2[j][i] += sum1[j][n] - sum1[j][i - 1];
      b2[j][i] += b2[j][i - 1];
    }
  }
  long long sum3 = 0, times = 0;
  for (int i = 1; i <= 1; i++) {
    for (int j = 1; j <= n; j++) {
      sum3 += a[i][j] * times;
      times++;
    }
  }
  for (int i = 2; i <= 2; i++) {
    for (int j = n; j >= 1; j--) {
      sum3 += a[i][j] * times;
      times++;
    }
  }
  r = sum3;
  return;
}
int main() {
  cin.tie(0), ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  calc();
  mx = r;
  long long res = 0, times = 1, sum3 = 0;
  for (int j = 1; j <= n; j++) {
    if (j % 2 != 0) {
      for (int i = 1; i <= 2; i++) {
        if (i == 1 && j == 1) {
          continue;
        }
        if (i == 1) {
          int ind = j - 1;
          sum3 = res;
          times--;
          sum3 += b1[1][ind + 1] + times * (sum1[1][n] - sum1[1][ind]);
          sum3 += b2[2][n] - b2[2][ind] +
                  (times + n - ind) * (sum1[2][n] - sum1[2][ind]);
          mx = max(mx, sum3);
          times++;
        } else {
          int ind = j;
          res += times * a[i][j];
          times--;
          sum3 = res;
          sum3 += b1[2][ind + 1] + times * (sum1[2][n] - sum1[2][ind]);
          sum3 += b2[1][n] - b2[1][ind] +
                  (times + n - ind) * (sum1[1][n] - sum1[1][ind]);
          mx = max(mx, sum3);
          times++;
          times++;
        }
        if (i == 1) {
          res += times * a[i][j];
          times++;
        }
      }
    } else {
      for (int i = 2; i >= 1; i--) {
        if (i == 2) {
          int ind = j - 1;
          sum3 = res;
          times--;
          sum3 += b1[2][ind + 1] + times * (sum1[2][n] - sum1[2][ind]);
          sum3 += b2[1][n] - b2[1][ind] +
                  (times + n - ind) * (sum1[1][n] - sum1[1][ind]);
          mx = max(mx, sum3);
          times++;
        } else {
          int ind = j;
          res += times * a[i][j];
          sum3 = res;
          times--;
          sum3 += b1[1][ind + 1] + times * (sum1[1][n] - sum1[1][ind]);
          sum3 += b2[2][n] - b2[2][ind] +
                  (times + n - ind) * (sum1[2][n] - sum1[2][ind]);
          mx = max(mx, sum3);
          times++;
          times++;
        }
        if (i == 2) {
          res += a[i][j] * times;
          times++;
        }
      }
    }
  }
  mx = max(mx, res);
  cout << mx << "\n";
}
