#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  long long int minElec = LONG_LONG_MAX;
  for (int i = 0; i < n; ++i) {
    long long int currElec = 0;
    for (int j = 0; j < n; ++j) currElec += arr[j] * 2 * (abs(i - j) + i + j);
    minElec = min(minElec, currElec);
  }
  cout << minElec;
  return 0;
}
