#include <cstdio> #include <iostream> using namespace std; int n,a[100010],ans; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); if(a[i]>a[i-1])ans+=a[i]-a[i-1]; } printf("%d ",ans); return 0; }
#include <cstdio> #include <iostream> using namespace std; int n,a[100010],ans; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); if(a[i]>a[i-1])ans+=a[i]-a[i-1]; } printf("%d ",ans); return 0; }