#include <bits/stdc++.h>
using namespace std;
int n, mn = 1e9;
vector<int> v;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      cnt += v[j] * (2 * abs(i - j) + 2 * j + 2 * i);
    }
    mn = min(mn, cnt);
  }
  cout << mn << endl;
}
