#include <bits/stdc++.h>
using namespace std;
void cal(int a[], int n) {
  int sum = 0, p, q;
  n = n / 2;
  for (int i = 0; i < n; i++) {
    int temp;
    p = a[i] * (abs((i + 1) - (n + i + 1)));
    q = a[n + i] * (abs((n + i + 1) - (i + 1)));
    temp = a[i];
    a[i] = a[n + i];
    a[n + i] = temp;
    sum = sum + p + q;
  }
  cout << sum;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cal(a, n);
  return 0;
}
