#include <bits/stdc++.h>
using namespace std;
int a[105];
inline int abs(int x) { return (x < 0) ? -x : x; }
inline int min(int x, int y) { return x < y ? x : y; }
int main() {
  int n;
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int ans = 0x7fffffff;
  for (int j = 1; j <= n; ++j) {
    int temp = 0;
    for (int i = 1; i <= n; ++i) {
      temp += (2 * a[i] * (abs(j - i) + abs(i - 1) + abs(j - 1)));
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
