#include <iostream>
#include<algorithm>
using namespace std;
int main() {
int n,s=0,tot=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<n;i++){
s=s+a[i];
i++;
}
for(int i=0;i<n;i++){
tot=tot+a[i];
}
cout<<max({s,tot-s})<<" "<<min({s,tot-s});
}
To embed this project on your website, copy the following code and paste it into your website's HTML: