#include <bits/stdc++.h>
using LL = long long;
using ULL = unsigned long long;
using namespace std;
long long n;
signed main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  cin >> n;
  vector<long long> a(n + 1, -1);
  for (long long i = (1); i < (n + 1); i++) cin >> a[i];
  long long ma = 2147483647;
  for (long long x = (1); x < (n + 1); x++) {
    long long cnt = 0;
    for (long long i = (1); i < (n + 1); i++)
      cnt += a[i] * (abs(x - i) + abs(i - 1) + abs(x - 1) + abs(x - 1) +
                     abs(i - 1) + abs(x - i));
    ma = min(ma, cnt);
  }
  cout << ma << '\n';
  return 0;
}
