func_code_string: #include <bits/stdc++.h>   using namespace std;   #pragma warning(disable : 4996);   long long int n, h[1000007], d[1000007][2], mod = 1e9 + 7;   void solve() {     long long int i, j;     cin >> n;     for (i = 0; i < n; i++) {       cin >> h[i];       h[i] -= 1;     }     h[n] = 0;     d[0][0] = max((long long int)0, h[0] - h[1]);     d[0][1] = min(h[0], h[1]);     for (i = 1; i < n; i++) {       long long int k = min(h[i - 1], h[i]);       d[i][0] = d[i - 1][1] * max((long long int)0, k - h[i + 1]);       d[i][0] %= mod;       d[i][0] = (d[i][0] + max((long long int)0, h[i] - h[i + 1])) % mod;       d[i][1] = d[i - 1][1] * min(h[i + 1], k);       d[i][1] %= mod;       d[i][1] = (d[i][1] + min(h[i], h[i + 1])) % mod;     }     long long int ans = 0;     for (i = 0; i < n; i++) {       ans = (ans + d[i][0] + d[i][1]) % mod;     }     cout << ans;   }   int main() {   #pragma comment(linker,  /STACK:1073741824      solve();     return 0;   }   