#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    
    vector<int> W(10),K(10);
    
    for(int i=0;i<10;i++) scanf("%d",&W[i]);
    for(int i=0;i<10;i++) scanf("%d",&K[i]);
    
    sort(W.begin(),W.end());
    sort(K.begin(),K.end());
    
    printf("%d %d\n",W[7]+W[8]+W[9],K[7]+K[8]+K[9]);
    
    return 0;
}
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int sum[2] = {0}, num[10] = { 0 }, i, j;
	for (j = 0; j < 2; j++) {
		for (i = 0; i < 10; i++) {
			cin >> num[i];
		}
		sort(num, num + 10);
		sum[j] = num[7] + num[8] + num[9];
	}
	cout << sum[0] << " " << sum[1] << endl;
	return 0;
}