func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MaxN = 1e6;   const long long Inf = 0x3f3f3f3f3f3f3f3f;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const double eps = 1e-7;   template <class T>   inline void read(T &res) {     char c;     T flag = 1;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) flag = -1;     res = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) res = res * 10 + c -  0 ;     res *= flag;   }   long long dp[MaxN + 5][2], r1, r2, r3, d;   long long a[MaxN + 5];   int n;   int main() {     memset(dp, 0x3f, sizeof dp);     cin >> n >> r1 >> r2 >> r3 >> d;     for (int i = 1; i <= n; ++i) cin >> a[i];     dp[1][0] = a[1] * r1 + r3;     dp[1][1] = min((a[1] + 1) * r1, r2);     for (int i = 1; i < n; ++i) {       dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + d + a[i + 1] * r1 + r3);       dp[i + 1][0] =           min(dp[i + 1][0], dp[i][1] + d + (a[i + 1] + 1) * r1 + 2 * d + r1 + r1);       dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + d + r2 + d + r1 + d + r1);       dp[i + 1][0] =           min(dp[i + 1][0], dp[i][1] + d + a[i + 1] * r1 + r3 + 2 * d + r1);       dp[i + 1][1] =           min(dp[i + 1][1], dp[i][0] + d + min((a[i + 1] + 1) * r1, r2));       dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + d + r2 + d + r1 + d);       dp[i + 1][1] =           min(dp[i + 1][1], dp[i][1] + d + 2 * d + r1 + (a[i + 1] + 1) * r1);       if (i + 1 == n) {         dp[i + 1][0] =             min(dp[i + 1][0], dp[i][1] + d + a[i + 1] * r1 + r3 + d + r1);       }     }     cout << dp[n][0] << endl;     return 0;   }   