#include <bits/stdc++.h>
using namespace std;
int v[101];
int modul(int x) {
  if (x < 0) return -x;
  return x;
}
int main() {
  int n, s, i, x, sum, poz;
  scanf("%d", &n);
  s = 2000000000;
  for (i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
  }
  for (x = 1; x <= n; x++) {
    sum = 0;
    for (i = 1; i <= n; i++) {
      sum = sum + 2 * v[i] * (modul(x - i) + i - 1 + x - 1);
    }
    if (sum < s) {
      s = sum;
      poz = x;
    }
  }
  printf("%d", s);
  return 0;
}
