#include <bits/stdc++.h>
using namespace std;
long long a[100010];
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long ans = 1e9;
  for (long long i = 1; i <= n; i++) {
    long long cnt = 0;
    for (long long j = 1; j <= n; j++) {
      long long temp = a[j] * (abs(i - j) + abs(j - 1) + abs(i - 1) +
                               abs(1 - i) + abs(1 - j) + abs(j - i));
      cnt += temp;
    }
    ans = min(ans, cnt);
  }
  cout << ans << "\n";
}
