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