#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n, i, ans, s, j, sum = 0, x;
  long long person[1000];
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &person[i]);
  }
  long long min_charge = 99999999990999;
  for (x = 1; x <= n; x++) {
    long long charge = 0;
    for (long long floor = 1; floor <= n; floor++) {
      if (x > floor) {
        charge += person[floor - 1] * 2 * (x - 1) * 2;
      } else {
        charge += 2 * person[floor - 1] * ((floor - x) + (floor - 1) + (x - 1));
      }
    }
    min_charge = min(charge, min_charge);
  }
  cout << min_charge << endl;
  return 0;
}
