#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  int* a = new int[n];
  int m = -1, floor = 1;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  floor = 1;
  int electricity = 0;
  for (i = 0; i < n; i++) {
    electricity += (abs(i + 1 - floor) + (i + 1 - 1) + abs(floor - 1)) * a[i];
    electricity +=
        (abs(floor - 1) + abs(i + 1 - 1) + abs(i + 1 - floor)) * a[i];
  }
  cout << electricity << "\n";
}
