func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MAX = 5005;   vector<long long> arr(MAX);   long long solve(long long l, long long r, long long cur) {     if (l > r) return 0;     long long mn = arr[l], idx = l;     for (int i = l; i <= r; i++) {       if (arr[i] < mn) {         mn = arr[i];         idx = i;       }     }     return min(r - l + 1,                solve(l, idx - 1, mn) + solve(idx + 1, r, mn) + mn - cur);   }   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     int ans = 0;     for (int i = 0; i < n; i++) cin >> arr[i];     cout << solve(0, n - 1, 0) << endl;     return 0;   }   