#include <bits/stdc++.h>
using namespace std;
int vis[1000];
int Pow[5];
int change(string p) {
  int sum = 0;
  for (int i = 0; i < p.size(); i++) {
    sum += (p[i] - 48);
    sum *= 10;
  }
  return sum / 10;
}
string minstr(string s) {
  int i = 0, j = 1, k = 0;
  int len = s.size();
  while (j < len && i < len && k < len) {
    char tmp = s[(i + k) % len] - s[(j + k) % len];
    if (tmp == 0) {
      ++k;
    } else {
      if (tmp < 0) j += k + 1;
      k = 0;
      if (tmp > 0) i = i + k + 1;
      if (i == j) j++;
    }
  }
  int t = max(i, j);
  string p = s.substr(t) + s.substr(0, t);
  return p;
}
void init() {
  vis[0] = ' ';
  for (int i = 0; i < 26; i++) {
    vis[i + 1] = i + 'A';
  }
  vis[27] = '\'';
  vis[29] = '-';
  vis[28] = ',';
  vis[30] = '.';
  vis[31] = '?';
  Pow[0] = 1;
  for (int i = 1; i < 5; i++) {
    Pow[i] = Pow[i - 1] * 2;
  }
}
int a[100000];
int main() {
  int n;
  while (cin >> n) {
    int dex = 0;
    int minn = 9999999;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        sum += ((abs(j - i) + (j - 1)) + (i - 1)) * a[j] * 2;
      }
      if (sum < minn) {
        minn = sum;
        dex = i;
      }
    }
    cout << minn << endl;
  }
  return 0;
}
