#include <bits/stdc++.h>
using namespace std;
long long const MAXN = 5005;
long long n;
long long data[107];
long long solve(long long x) {
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    ans += data[i] * (abs(x - i) + i + x);
    ans += data[i] * (x + i + abs(x - i));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; ++i) cin >> data[i];
  long long ans = 1e15;
  for (long long i = 0; i < n; ++i) ans = min(ans, solve(i));
  cout << ans << '\n';
  return 0;
}
