#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
using namespace std;int sum=0,cnt=0;int mini=0x3f3f3f3f;int f=0;int n=0;
void dfs(int i,vector<int>& nums,int s){ 
   if(i>=n||f||cnt==sum/2) return;
    if(nums[i]>sum/2) {f=1;cnt=nums[i];return;}//当前元素的值大于一半的总和,这个元素单独一组,其他dfs可以结束
    int now=abs(sum-2*s);//计算当前差值绝对值
    if(now<mini) {mini=now;cnt=s;}//更新最小差值,更新答案
    if(s>=sum/2) return;//无需后续dfs
    dfs(i+1,nums,s+nums[i]);//加上当前元素
    dfs(i+1,nums,s);//不加
}
int main() {
    stringstream ss;
string s;
    while (getline(cin,s)) { // 注意 while 处理多个 case
     vector<int> nums; sum=0;cnt=0;mini=0x3f3f3f3f;f=0;
       ss.clear();ss.str(""); ss<<s;int flag=0;
        while (ss>>s) {
         for(int i=0;i<s.size();i++){
            if(!isdigit(s[i])) {flag=1;break;}
        }
     if(flag) break;  
 nums.push_back(stoi(s));sum+=stoi(s);
}
 if(flag) {cout<<"ERROR"<<endl;continue;}n=nums.size();
dfs(0,nums,0);
cout<<max(cnt,sum-cnt)<<' '<<min(cnt,sum-cnt)<<endl;
    }
}