#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
int main() {
  cout.tie(0);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  int Ans = INF;
  for (int c = 1; c <= n; ++c) {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      ans += a[i] * 4 * (max(i + 1, c) - 1);
    }
    Ans = min(ans, Ans);
  }
  cout << Ans << endl;
  return 0;
}
