#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[105], i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = INT_MAX;
  for (i = 0; i < n; i++) {
    int sum = 0;
    for (int k = 0; k < n; k++) {
      sum = sum + arr[k] * (abs(k - i) + i) * 4;
    }
    ans = min(sum, ans);
  }
  cout << ans << endl;
}
