#include <bits/stdc++.h>
using namespace std;
const int MX = 109;
using ull = unsigned long long int;
using ld = long double;
using ll = signed long long int;
int a[MX], res_units, cunits, n;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  res_units = numeric_limits<int>::max();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cunits = 0;
    for (int j = 0; j < n; j++) {
      cunits += a[j] * ((abs(i - j) + j + i) * 2);
    }
    res_units = min(res_units, cunits);
  }
  cout << res_units << endl;
}
