func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int h[1000010], f[1000010][2];   void Work() {     int ans = 0;     for (int i = 1; i <= n; i++) {       int l, r;       l = min(h[i - 1], h[i]);       r = min(h[i], h[i + 1]);       if (l <= r)         f[i][1] = 1LL * f[i - 1][1] * l % 1000000007;       else {         f[i][1] = 1LL * f[i - 1][1] * r % 1000000007;         f[i][0] = 1LL * f[i - 1][1] * (l - r) % 1000000007;       }       f[i][1] += min(h[i], h[i + 1]);       f[i][0] += h[i] - min(h[i], h[i + 1]);       ans = ((long long)ans + f[i][1] + f[i][0]) % 1000000007;     }     printf( %d n , ans);   }   void Init() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &h[i]), h[i]--;     h[n + 1] = 0x7f7f7f7f;   }   int main() {     Init();     Work();     return 0;   }   