func_code_string: #include <bits/stdc++.h>   const int M = 1000005;   long long f[M];   int A[M];   int n;   int Min(int a, int b) { return a < b ? a : b; }   int Max(int a, int b) { return a < b ? b : a; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , A + i);     long long ans = 0;     A[0] = 1;     for (int i = 1; i <= n; ++i) {       (ans += A[i] - 1) %= 1000000007;       (ans += f[i - 1] * (Min(A[i], A[i - 1]) - 1)) %= 1000000007;       (f[i] += Min(A[i], A[i + 1]) - 1) %= 1000000007;       (f[i] += Max(0, Min(Min(A[i], A[i - 1]), A[i + 1]) - 1) * f[i - 1]) %=           1000000007;     }     printf( %lld n , (ans + 1000000007) % 1000000007);     return 0;   }   