#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
int k;
int a[100];
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 2000000000;
  for (int x = 1; x <= n; x++) {
    int newans = 0;
    for (int i = 1; i <= n; i++) {
      newans += a[i] * 2 * (abs(x - i) + abs(1 - i) + abs(x - 1));
    }
    ans = min(ans, newans);
  }
  cout << ans << '\n';
}
