#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;
int main(void){
   vector<int> w(10);
   vector<int> k(10);
   int sumw=0,sumk=0;
   
   for(int i=0;i<10;i++)cin>>w[i];
   for(int i=0;i<10;i++)cin>>k[i];
   
   sort(w.begin(),w.end());
   sort(k.begin(),k.end());
   
   for(int i=9;i>6;i--) {
       sumw+=w[i];
       sumk+=k[i];
   }
        
    cout<<sumw<<" "<<sumk<<endl;
    
    
    return 0;
}
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int a[10], b[10];

int main(){
  REP(i,10) a[i] = getInt();
  REP(i,10) b[i] = getInt();
  sort(a, a+10); sort(b, b+10);
  cout << a[9] + a[8] + a[7] << " " << b[9] + b[8] + b[7] << endl;
  return 0;
}