#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int min = 1e9;
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      ans += (abs(j - i) + j + i) * 2 * arr[j];
    }
    if (min > ans) min = ans;
  }
  cout << min << endl;
}
