algorithm_2024/src/P5019/P5019.cpp
2024-10-16 10:53:15 +08:00

41 lines
649 B
C++

#include <cctype>
#include <cstdio>
#include <iostream>
using ll = long long;
ll n,a,b,ans;
struct ReadLL{
char c;
ll n,w;
ReadLL&operator>>(ll &num)noexcept{
c=0,n=0,w=1;
while(!isdigit(c)){
if(c=='-')w=-1;
c=getchar();
}
while(isdigit(c)){
n=n*10+c-'0';
c=getchar();
}
num=n*w;
return *this;
}
}readll;
// auto &is = std::cin;
auto &is = readll;
auto &os = std::cout;
int main(){
is>>n;
for(ll i{0};i!=n;i++){
is>>b;
if(b>a){
ans+=b-a;
}
a=b;
}
os<<ans<<'\n';
}