#include <bits/stdc++.h>
using namespace std;
const long long mx = (1e5) + 1;
const long long mod = 1000000007;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int x = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      continue;
    } else {
      int s = abs((i + 1) - x) * 4;
      ans += s * a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
