#include <bits/stdc++.h>
using namespace std;
const int mod = 7 + 1e9;
const int inf = 1e9;
const int N = 111;
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int tot = 0;
  for (int i = 1; i < (int)(n + 1); i++) {
    cin >> a[i];
    tot += a[i] * (i + 1);
  }
  int ans = inf;
  int cnt = 0;
  for (int id = 1; id <= n; ++id) {
    cnt = 0;
    for (int i = 1; i < (int)(n + 1); i++) {
      int cc = abs(id - i) + i - 1 + id - 1 + id - 1 + i - 1 + abs(id - i);
      cc *= a[i];
      cnt += cc;
    }
    ans = min(ans, cnt);
  }
  cout << ans << "\n";
}
