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