无脑DP
#include<bits/stdc++.h>
using namespace std;
int maxProfit(int* prices, int pricesSize){
if(pricesSize <= 1) return 0;
int i = 0,* _prices,sum = 0;
_prices = (int *)malloc(sizeof(int) * pricesSize);
_prices[0] = 0;
for(i = 1;i < pricesSize;i++){
_prices[i] = prices[i] - prices[i - 1];
if (_prices[i] > 0) sum += _prices[i];
}
return sum;
}
int main(){
int pricesSize;
cin >> pricesSize;
int prices[pricesSize];
for(int i = 0;i < pricesSize;i++)
cin >> prices[i];
cout << maxProfit(prices,pricesSize);
}