func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long int a[n + 1];     a[0] = 0ll;     long long int ans = 0ll;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] > a[i - 1]) ans += (1ll * (a[i] - a[i - 1]) * (n - a[i] + 1));       if (a[i] < a[i - 1]) ans += (1ll * a[i] * (a[i - 1] - a[i]));     }     cout << ans;   }   