#include <bits/stdc++.h>
void IO(bool inp, bool out) {
  if (inp) freopen("k.inp", "r", stdin);
  if (out) freopen("k.out", "w", stdout);
}
using namespace std;
int n, a[101];
int kq = 1000000000;
int main() {
  IO(0, 0);
  scanf("%d", &n);
  for (short i = 0; i < n; ++i) scanf("%d", &a[i]);
  int dem;
  for (short i = 0; i < n; ++i) {
    dem = 0;
    for (short j = 0; j < n; ++j) dem += ((abs(i - j) + i + j)) * 2 * a[j];
    kq = min(kq, dem);
  }
  printf("%d", kq);
}
