#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long INFMAX = 1e18, INFMIN = -1e18;
const long long N = 200000 + 10;
vector<long long> adj[N];
void peace() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long xx;
    cin >> xx;
    ans += (4 * (i)*xx);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) peace();
}
