Pagini recente » Cod sursa (job #2392739) | Rezultatele filtrării | Cod sursa (job #2504778) | Cod sursa (job #2405410) | Cod sursa (job #2540484)
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;
int main()
{
freopen("operatii.in","r",stdin);
freopen("operatii.out","w",stdout);
int n , x;
long long sum = 0;
int threshold=0;
scanf("%d",&n);
for(int i = 1 ; i <= n ; i++)
{
scanf("%d",&x);
if(x > threshold)
{
sum += 1ll*x-1ll*threshold;
threshold = x;
continue;
}
else
threshold = x;
}
printf("%lld\n",sum);
return 0;
}