#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<deque>
using namespace std;
int main(){
deque < int > Q;
int n, temp;
cin >> n;
for( int i = 0; i < n; ++i ){
cin >> temp;
Q.push_back( temp );
}
int sum1 = 0, sum2 = 0;
int temp1 = 0;
while( !Q.empty() ){
int x1 = Q.front();
int x2 = Q.back();
if( x1 > x2 ){
temp = x1;
Q.pop_front();
}
else{
temp = x2;
Q.pop_back();
}
if( temp1 % 2 == 0 ){
sum1 += temp;
}
else{
sum2 += temp;
}
temp1++;
}
cout << sum1 << " " << sum2 << endl;
return 0;
}