#include <bits/stdc++.h>
#define pi 3.14159265359
using namespace std;
int main() {
int N;
cin >> N;
vector<int> A(N);
long long ans =0, St =0;
for(int i =0; i < N; i++) {
cin >> A[i];
St +=A[i];}
if(N%2 != 0) {N++; A.push_back(0);}
multiset<int> S;
for(int i =0; i < N/2; i++) {
ans +=A[2*i];
S.insert(A[2*i]);
if(A[2*i+1] > *S.begin()) {
ans +=A[2*i+1]-*S.begin();
S.erase(S.begin());
S.insert(A[2*i+1]);}
}
cout << ans << " " << St-ans << "\n";
return 0;}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGkgMy4xNDE1OTI2NTM1OQp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgTjsKCWNpbiA+PiBOOwoJdmVjdG9yPGludD4gQShOKTsKCWxvbmcgbG9uZyBhbnMgPTAsIFN0ID0wOwoJZm9yKGludCBpID0wOyBpIDwgTjsgaSsrKSB7CgkJY2luID4+IEFbaV07CgkJU3QgKz1BW2ldO30KCWlmKE4lMiAhPSAwKSB7TisrOyBBLnB1c2hfYmFjaygwKTt9CgltdWx0aXNldDxpbnQ+IFM7Cglmb3IoaW50IGkgPTA7IGkgPCBOLzI7IGkrKykgewoJCWFucyArPUFbMippXTsKCQlTLmluc2VydChBWzIqaV0pOwoJCWlmKEFbMippKzFdID4gKlMuYmVnaW4oKSkgewoJCQlhbnMgKz1BWzIqaSsxXS0qUy5iZWdpbigpOwoJCQlTLmVyYXNlKFMuYmVnaW4oKSk7CgkJCVMuaW5zZXJ0KEFbMippKzFdKTt9CgkJfQoJY291dCA8PCBhbnMgPDwgIiAiIDw8IFN0LWFucyA8PCAiXG4iOwoJcmV0dXJuIDA7fQ==