每日一题:https://www.luogu.com.cn/problem/P5019
题目链接:https://www.luogu.com.cn/problem/P5019
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n+1];
int sum=0;
arr[0]=0;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
for(int i=0;i<n;i++){
arr[i]=arr[i+1]-arr[i];
if(arr[i]>0){
sum+=arr[i];
}
}
cout<<sum<<endl;
return 0;
}