#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
char h[3]={" \n"};
int main()
{
int w[3],x;
for(int j=0;j<2;j++){
 memset(w,0,sizeof(w));
 for(int i=0;i<10;i++){
 scanf("%d",&x);
 if(x>w[0]){w[2]=w[1]; w[1]=w[0]; w[0]=x;}
 else if(x>w[1]) {w[2]=w[1]; w[1]=x;}
 else if(x>w[2]) w[2]=x;
 }
 printf("%d%c",w[0]+w[1]+w[2],h[j]);
}
}
#include <iostream>
#include <algorithm>
using namespace std;

int main () {
	int w[10];
	int k[10];
	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);
	int wSum = 0, kSum = 0;
	for (int i = 9; i > 6; i--) {
		wSum += w[i];
	}
	for (int i = 9; i > 6; i--) {
		kSum += k[i];
	}
	cout << wSum << " " << kSum << endl;
	return 0;
}