#include <bits/stdc++.h>
using namespace std;
int a[200];
int main() {
  int n, ans, M = 9999999;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 1; j <= n; j++) ans += (abs(i - j) + j + i - 2) * 2 * a[j];
    if (ans < M) M = ans;
  }
  cout << M;
}
