#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
template <class T, class U>
istream &operator>>(istream &in, pair<T, U> &p) {
  in >> p.first >> p.second;
  return in;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <class T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &i : v) {
    in >> i;
  }
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (auto &i : v) {
    out << i << ' ';
  }
  return out;
}
inline void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  cout << fixed << setprecision(15);
}
long long bin_pow(long long a, long long b) {
  return b == 0 ? 1 : (b % 2 ? bin_pow(a, b - 1) * a : bin_pow(a * a, b / 2));
}
bool prime(long long n) {
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) return false;
  return true;
}
const int INFI = 1e9;
int main() {
  io();
  long long n, mini = INFI;
  cin >> n;
  vector<long long> a(n);
  cin >> a;
  for (int i = 0; i < n; ++i) {
    long long sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += a[j] * 2 * (i + j + (abs(i - j)));
    }
    mini = min(mini, sum);
  }
  cout << mini;
}
