#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define el <<endl
// void doma()
// {
// ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("output.txt", "w", stdout);
// #endif
// }
int main()
{
int n;
cin >> n;
int arr[n];
for(int i=0; i<n; i++)
cin >> arr[i];
sort(arr,arr+n); // lower order
long long sereja_sum=0;
long long dima_sum=0;
for (int i = n-1; i >=0; i--)
{
if (n%2 !=0) // n is odd
{
if (i%2 == 0) // even sereja_sum
{
sereja_sum += arr[i];
}
else if (i%2!=0) // odd dima_sum
{
dima_sum += arr[i];
}
}
else // n is even
{
if (i%2 != 0) // odd sereja_sum
{
sereja_sum += arr[i];
}
else if (i%2==0) // even dima_sum
{
dima_sum += arr[i];
}
}
}
cout << sereja_sum << " " << dima_sum << nl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBubCAiXG4iCiNkZWZpbmUgZWwgPDxlbmRsIAoKLy8gdm9pZCBkb21hKCkKLy8gewovLyAgICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSksIGNpbi50aWUoTlVMTCksIGNvdXQudGllKE5VTEwpOwovLyAjaWZuZGVmIE9OTElORV9KVURHRQovLyAgICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7Ci8vICNlbmRpZgovLyB9CgppbnQgbWFpbigpCnsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICBpbnQgYXJyW25dOwogICAgZm9yKGludCBpPTA7IGk8bjsgaSsrKQogICAgICAgIGNpbiA+PiBhcnJbaV07CgogICAgc29ydChhcnIsYXJyK24pOyAvLyBsb3dlciBvcmRlcgoKICAgCgogICAgbG9uZyBsb25nIHNlcmVqYV9zdW09MDsKICAgIGxvbmcgbG9uZyBkaW1hX3N1bT0wOwoKICAgIGZvciAoaW50IGkgPSBuLTE7IGkgPj0wOyBpLS0pCiAgICB7CiAgICAgIGlmIChuJTIgIT0wKSAvLyBuIGlzIG9kZAogICAgICB7CiAgICAgICAgICAgaWYgKGklMiA9PSAwKSAvLyBldmVuIHNlcmVqYV9zdW0KICAgICAgICAgICB7CiAgICAgICAgICAgc2VyZWphX3N1bSArPSBhcnJbaV07CiAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmIChpJTIhPTApIC8vIG9kZCBkaW1hX3N1bQogICAgICAgICAgICB7CiAgICAgICAgICAgICBkaW1hX3N1bSArPSBhcnJbaV07CiAgICAgICAgICAgIH0KCiAgICAgIH0KCiAgICAgIGVsc2UgLy8gbiBpcyBldmVuCiAgICAgIHsKCiAgICAgICAgICAgIGlmIChpJTIgIT0gMCkgLy8gb2RkIHNlcmVqYV9zdW0KICAgICAgICAgICB7CiAgICAgICAgICAgc2VyZWphX3N1bSArPSBhcnJbaV07CiAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmIChpJTI9PTApIC8vIGV2ZW4gZGltYV9zdW0KICAgICAgICAgICAgewogICAgICAgICAgICAgZGltYV9zdW0gKz0gYXJyW2ldOwogICAgICAgICAgICB9CiAgICAgICAgCiAgICAgIH0KCiAgICB9CiAgICAKICAgIGNvdXQgPDwgc2VyZWphX3N1bSA8PCAiICIgPDwgZGltYV9zdW0gPDwgbmw7CgoKICAgIHJldHVybiAwOwp9