func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 7;   const int MOD = 1e9 + 7;   long long a[maxn];   int main() {     int n;     scanf( %d , &n);     long long ans = 0;     for (int i = 1; i <= n; ++i) {       scanf( %lld , &a[i]);       ans += a[i] * (n - a[i] + 1);       if (i == 1) continue;       long long t1 = a[i - 1], t2 = a[i];       if (t1 > t2) swap(t1, t2);       ans -= t1 * (n - t2 + 1);     }     printf( %lld n , ans);     return 0;   }   