#include <bits/stdc++.h>
using namespace std;
int N, s[110];
long long sum, mi = 0x3f3f3f3f;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &s[i]);
  for (int i = 1; i <= N; i++) {
    sum = 0;
    for (int j = 1; j <= N; j++)
      sum += (abs(j - i) + abs(i - 1) + abs(j - 1)) * 2 * s[j];
    mi = min(mi, sum);
  }
  printf("%lld\n", mi);
  return 0;
}
