#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
clock_t time_p = clock();
void timer() {
  time_p = clock() - time_p;
  cerr << "Execution Time: " << (double)(time_p) / CLOCKS_PER_SEC << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, mi = 1000000000;
  cin >> n;
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  for (long long x = 1; x <= n; x++) {
    long long temp = 0;
    for (long long a = 1; a <= n; a++) {
      temp += (2 * abs(a - x) + 2 * abs(x - 1) + 2 * abs(a - 1)) * arr[a];
    }
    mi = min(mi, temp);
  }
  cout << mi;
  timer();
  return 0;
}
