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