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