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