#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int main() {
  int n;
  scanf("%d", &n);
  int a[maxn] = {0};
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int ans = 1e9, sum = 0, pos;
  for (int i = 1; i <= n; i++) {
    int p = i;
    sum = 0;
    for (int j = 1; j <= n; j++) {
      sum += (abs(j - p) + abs(j - 1) + abs(1 - p)) * a[j] * 2;
    }
    if (sum < ans) ans = sum;
  }
  printf("%d\n", ans);
}
