#include <bits/stdc++.h>
using namespace std;
int ar[100005];
int main() {
  long long n, i, ans = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
    ans += (abs(1 - i) * 4) * ar[i];
  }
  cout << ans << endl;
}
