Code:
#include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) #define ll long long #define maxn 100034 using namespace std; ll a[maxn]; int main() { // setIO("input"); int n; scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%lld",&a[i]); ll pos=0,neg=0; for(int i=n;i>1;--i) { if(a[i-1] > a[i]) pos+=a[i-1]-a[i]; else neg+=a[i]-a[i-1]; } printf("%lld %lld",max(pos, neg), abs(pos-neg)+1); return 0; }