#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  long long int x = ((n + 1) / 2);
  long long int sum = 0;
  for (long long int i = 0, j = x; i < x, j < n; i++, j++) {
    sum += arr[i] * abs(i - j);
    long long int temp = arr[j];
    arr[j] = arr[i];
    arr[i] = temp;
  }
  for (long long int i = 0, j = x; i < x, j < n; i++, j++) {
    sum += arr[i] * abs(i - j);
    long long int temp = arr[j];
    arr[j] = arr[i];
    arr[i] = temp;
  }
  cout << sum;
  return 0;
}
