#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int arr[N];
int main(){
int n, k;
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d", &arr[i]);
}
int res = 0;
for(int i = 1; i < n; i++){
//从左往右统计差值 如果左边的高则把高的清除掉
res += max(0, arr[i-1]- arr[i]);
}
res += arr[n-1];
printf("%d\n", res);
return 0;
}
种花
最新推荐文章于 2024-09-16 16:08:41 发布