#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std ::ios ::sync_with_stdio(false);
  int n, mini = INT_MAX;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int x = 1; x <= n; x++) {
    int sum = 0;
    for (int j = 1; j <= n; j++) {
      sum += arr[j] * 2 * (abs(x - j) + (j - 1) + abs(x - 1));
    }
    mini = min(mini, sum);
  }
  cout << mini << endl;
  return 0;
}
