#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int min = INT_MAX;
  for (int x = 0; x < n; x++) {
    int v = 0;
    for (int i = 0; i < n; i++) {
      v += 2 * a[i] * (abs(x - i) + i + x);
    }
    if (v < min) min = v;
  }
  cout << min;
}
