#include <bits/stdc++.h>
using namespace std;
long long int a[102];
int main() {
  long long int n, i, j, sum, temp_sum;
  while (cin >> n) {
    for (i = 0; i < n; ++i) {
      cin >> a[i];
    }
    sum = 100000000;
    for (i = 1; i <= n; ++i) {
      temp_sum = 0;
      for (j = 1; j <= n; ++j) {
        temp_sum = temp_sum +
                   (a[j - 1] * (2 * (abs(i - j) + abs(j - 1) + abs(1 - i))));
      }
      if (sum > temp_sum) sum = temp_sum;
    }
    cout << sum << endl;
  }
  return 0;
}
