#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<ctime>
using namespace std;
int n,s,a[110];
int main(){
srand(time(0));
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i],s+=a[i];
int ans=9999999;
for(int k=1;k<=100000;k++){
for(int i=1;i<=n;i++){
int x=rand()%n+1;
int y=rand()%n+1;
swap(a[x],a[y]);
}
int t=0;
for(int i=1;i<=n/2;i++) t+=a[i];
int tans=abs(s-t-t);
if(ans>tans) ans=tans;
}
printf("%d %d\n",(s-ans)/2,(s+ans)/2);
return 0;
}