贪心
#include <iostream>
using namespace std;
const int N = 100005;
int a[N], n;
int main()
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
int res = 0;
for(int i = 1; i < n; i++)
{
res += max(0, a[i + 1] - a[i]); //在第a天买入,b天卖出,相当于在a,b之间,一天买入下一天就卖出
//利润大于等于零就卖出一定比小于零卖出的利润更高
}
cout << res << endl;
return 0;
}