Pagini recente » Rating Raul Gavris (gavrisraul) | Rating Ciprian O. (Pateu69) | Cod sursa (job #858064) | Cod sursa (job #2200744) | Cod sursa (job #1001214)
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int N, Last, Now;
long long Ans;
int main()
{
freopen("operatii.in", "r", stdin);
freopen("operatii.out", "w", stdout);
scanf("%i", &N);
for(int i = 1; i <= N; ++ i)
{
scanf("%i", &Now);
if(Now > Last) Ans += Now - Last;
Last = Now;
}
printf("%lld\n", Ans);
return 0;
}