#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	
	int a[10], b[10];
	
	for(int i = 0; i < 10; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < 10; i++){
		cin >> b[i];
	}
	
	sort(a, a + 10);
	sort(b, b + 10);
	
	printf("%d %d\n", (a[7] + a[8] + a[9]), (b[7] + b[8] + b[9]));
	
	return 0;
}
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int W[10],K[10];
  int score1=0,score2=0;
  for(int i=0;i<10;i++){
    cin >>W[i];
  }
  for(int i=0;i<10;i++){
    cin >>K[i];
  }
  
  sort(W,W+10);
  sort(K,K+10);

  for(int i=9;i>6;i--){
    score1+=W[i];}
  cout <<score1<<" ";
  for(int i=9;i>6;i--){
   score2+=K[i];}
  cout <<score2<<endl;
  return 0;
}