#include <bits/stdc++.h>
using namespace std;
int solve(int x, int i) {
  int ans = abs(i - x) + i + x;
  return 2 * ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  int mini = INT_MAX;
  for (int x = 1; x <= n; x++) {
    int total = 0;
    for (int i = 1; i <= n; i++) {
      total += arr[i] * solve(x - 1, i - 1);
    }
    mini = min(total, mini);
  }
  cout << mini << endl;
}
