#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[110];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    res += 4 * (max(i, 1) - 1) * arr[i];
  }
  cout << res << '\n';
  return 0;
}
