#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 ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    int temp = 0;
    for (int j = 0; j < n; j++) {
      int temp1 = 0;
      temp1 += 2 * abs(j - i);
      temp1 += 2 * abs(j);
      temp1 += 2 * abs(i);
      temp1 *= arr[j];
      temp += temp1;
    }
    ans = min(ans, temp);
  }
  cout << ans;
}
