#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, x, s = 0;
  cin >> n;
  x = n / 2;
  long long int a[n], b[n];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i] * 4 * (i - 1);
    s += b[i];
  }
  cout << s;
  return 0;
}
