#include<iostream>
using namespace std;
const int N = 100010;
int n;
int a[N],b[N];
int sum1 = 0,sum2 = 0;
int main()
{
int n;
cin>>n;
for(int i = 1; i<=n; i++)
{
cin>>b[i];
sum1+=b[i];
}
for(int i = 1; i<=n; i++)
if(b[i]>b[i-1])
sum2+=b[i];
cout<<sum1<<endl<<sum2;
return 0;
}