#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const long long OO = 1e18;
const int N = 1e5 + 5;
void Suhaib_Sawalha() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  long long ans(0), final_ans(INT_MAX);
  for (long long x = 0; x < n; ++x) {
    ans = 0;
    for (long long i = 0; i < n; ++i) ans += (i < x ? x : i) * 4 * arr[i];
    final_ans = min(final_ans, ans);
  }
  cout << final_ans;
}
void Suhaib_Sawalha1() {
  long long t;
  cin >> t;
  while (t--) {
    Suhaib_Sawalha();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Suhaib_Sawalha();
  return 0;
}
