#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[(int)1e5 + 5], i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  long long int val, min = 1000000000, tmp;
  for (i = 1; i <= n; i++) {
    tmp = 0;
    for (j = 1; j <= n; j++) {
      val = 0;
      val += (j - 1) * 2;
      val += (fabs(j - i) * 2) + (fabs(i - 1) * 2);
      val *= a[j - 1];
      tmp += val;
    }
    if (tmp < min) min = tmp;
  }
  printf("%lld\n", min);
  return 0;
}
