#include <bits/stdc++.h>
using namespace std;
int n;
int num[1005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  int ans = 1e9;
  for (int x = 1; x <= n; x++) {
    int now = 0;
    for (int i = 1; i <= n; i++) {
      int ton = abs(x - i) + i - 1 + x - 1;
      ton *= 2;
      now += ton * num[i];
    }
    ans = min(ans, now);
  }
  printf("%d\n", ans);
}
