#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long M = 1e6 + 5;
const double pi = acos(-1.);
const long long dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
const long long dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
long long a, c, b, d, e, f, g, h, i, j, k, l, n, o, p, q, r, s, t, u, w, x, y,
    z, maxi, mini, ans, mid, low, high, total;
string s1, s2;
vector<long long> answer;
int main() {
  cin >> n;
  long long a[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  mini = INT_MAX;
  for (i = 1; i <= n; i++) {
    ans = 0;
    for (j = 1; j <= n; j++) {
      ans += ((j - 1) + abs(j - i) + abs(i - 1)) * a[j] * 2;
    }
    mini = min(mini, ans);
  }
  cout << mini;
}
