#include <bits/stdc++.h>   using namespace std;   struct fastIO {     fastIO() { ios_base::sync_with_stdio(0); }   };   const int MAXN = 1e6 * 2;   long long n, a[MAXN], x, ans = MAXN, b;   int main() {     fastIO();     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     for (x = 0; x < n; x++) {       b = 0;       for (long long i = 0; i < n; i++) {         b += (abs(x - i) + i + x) * a[i] * 2;       }       if (0) cerr << ans << endl;       ans = min(ans, b);     }     cout << ans;     return 0;   }   