#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long a;
  cin >> a;
  long long m = 0;
  vector<long long> c;
  long long b[a];
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  for (int y = 0; y < a; y++) {
    m = 0;
    for (int i = 0; i < a; i++) {
      long long x = abs(i - y) + i + y;
      x = x * b[i] * 2;
      m = m + x;
    }
    c.push_back(m);
  }
  sort(c.begin(), c.end());
  cout << c[0];
  return 0;
}
