懒得开数组了qwq
#include <iostream>
using namespace std;
int n;
int now;
int ans;
int main()
{
cin >> n;
for(int i = 1;i <= n;i ++)
{
int x;
cin >> x;
if(now < x)
{
ans += x - now;
now = x;
}
else now = x;
}
cout << ans;
return 0;
}