func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 100;   long long a[N], f[N], g[N], r1, r2, r3, d;   int n;   long long nkb() { return min(r1, r2); }   long long cnkb(int i) { return min(r2, r1 * a[i] + nkb()); }   long long clear_go(int i) {     return min(r1 * a[i] + r3, cnkb(i) + d + d + nkb());   }   void Solve() {     cin >> n >> r1 >> r2 >> r3 >> d;     r1 = min(r1, r3);     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= n; ++i) f[i] = 1e18;     f[0] = 0;     f[1] = clear_go(1);     for (int i = 2; i <= n; ++i) {       f[i] = f[i - 1] + clear_go(i) + d;       if (i > 1) {         f[i] = min(f[i], f[i - 2] + cnkb(i - 1) + d + cnkb(i) + d + nkb() + d +                              nkb() + d * (i != 2));       }     }     g[n + 1] = 0;     g[n] = clear_go(n);     for (int i = n - 1; i >= 1; --i) {       g[i] = g[i + 1] + 2ll * d + min(cnkb(i) + nkb(), clear_go(i));     }     long long ans = min(g[1], f[n]);     for (int i = 1; i < n; ++i) {       ans = min(ans, f[i] + d + g[i + 1]);     }     cout << ans <<   n ;   }   int main() {     int test = 1;     while (test--) Solve();   }   