#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i, x, n;
  cin >> n;
  int a[n], units, ans = INT_MAX, j;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    units = 0;
    for (j = 0; j < n; j++) {
      units += max(i, j) * a[j];
    }
    if (units < ans) ans = units;
  }
  cout << ans * 4;
  return 0;
}
