#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int x = 0;
  int oon;
  int minn = 1000000000;
  for (int i = 1; i <= n; i++) {
    x = 0;
    oon = i;
    for (int j = 1; j <= n; j++) {
      x += ((2 * (i - 1)) + (2 * abs(j - 1)) + (2 * abs(j - i))) * a[j];
    }
    minn = min(minn, x);
  }
  cout << minn;
}
