func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[5050];   int solve(int l, int r, int h) {     int m, i;     if (l > r)       return 0;     else if (l == r)       return (a[l] > h);     else       for (i = m = l; i <= r; i++)         if (a[m] > a[i]) m = i;     return min(r - l + 1,                a[m] - h + solve(l, m - 1, a[m]) + solve(m + 1, r, a[m]));   }   int main() {     int i, j;     int n;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     cout << solve(0, n - 1, 0) << endl;     return 0;   }   