#include<cstdio>  
    #include<iostream>  
    #include<cstring>  
    using namespace std;  
    int dp[45010][105],w[105];  
    int max(int a,int b)  
    {  
        return a>b?a:b;  
    }  
    int main()  
    {  
        int i,j,k,n,sum,sum1,sum2,num,ans;  
        while(cin>>n)  
        {  
            sum=0;  
            for(i=1;i<=n;i++)  
            {  
                cin>>w[i];  
                sum+=w[i];  
            }  
            sum1=(sum+1)/2;  
            num=(n+1)/2;  
            memset(dp,-1,sizeof(dp));  
            dp[0][0]=0;  
            //cout<<"ok"<<endl;  
            for(i=1;i<=n;i++)  
            {  
                for(j=sum1;j>=w[i];j--)  
                {  
                    for(k=num;k>=1;k--)  
                    {  
                        if(dp[j-w[i]][k-1]!=-1)  
                            dp[j][k]=max(dp[j][k],dp[j-w[i]][k-1]+w[i]);  
                    }  
                }  
            }  
            ans=0;  
            for(i=0;i<=sum1;i++)  
            {  
                if(dp[i][num]>ans)  
                {  
                    ans=dp[i][num];  
                }  
                if(dp[i][num-1]>ans)  
                {  
                    ans=dp[i][num-1];  
                }  
            }  
            if(ans<sum-ans)  
            {  
                cout<<ans<<" "<<sum-ans<<endl;  
            }  
            else 
            {  
                cout<<sum-ans<<" "<<ans<<endl;  
            }  
        }  
    }