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