思路:
ACcode:
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+10;
int n,a[N],ans;
void solve() {
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
int ans=0;
for(int i=1;i<=n;i++){
if(a[i]>a[i-1]) ans+=a[i]-a[i-1];
}
cout<<ans<<"\n";
}
signed main() {
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int t=1;
//cin>>t;
while(t--) {
solve();
}
return 0;
}
over~