#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int v[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  int menor = 0x3f3f3f3f, aux;
  for (int i = 1; i <= n; i++) {
    aux = 0;
    for (int j = 1; j <= n; j++) {
      if (j == i) {
        aux += v[j] * (4 * (i - 1));
      } else if (i > j) {
        aux += v[j] * (4 * (i - 1));
      } else {
        aux += v[j] * (4 * (j - 1));
      }
    }
    menor = min(menor, aux);
  }
  cout << menor << endl;
  return 0;
}
