#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int &a : A) cin >> a;
  int mn = 1000000000;
  for (int i = 1; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      int f = j + 1;
      sum += 2 * (abs(f - i) + f - 1 + i - 1) * A[j];
    }
    mn = min(mn, sum);
  }
  cout << mn << endl;
  return 0;
}
