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