#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll n,h[10086],maxn;
int main(){
cin >> n;
for(ll i = 1;i <= n;i++){
cin >> h[i];
maxn = max(h[i],maxn);
}
ll he = 0,s = 0,cnt = 0;
while(he <= maxn){
he++;
for(ll i = 1;i <= n;i++){
if(h[i] >= he){
s++;
}else{
if(s > 0){
cnt++;
s = 0;
}
}
}
if(s>0){
cnt++;
s=0;
}
}
cout << cnt;
return 0;
}
WA最后两个点