#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[6];
int b,c,sum = 0;
int sub;
int mm;
int x1,y1,z1;
int min = 100000;
for(int i = 0; i < 6; i++) {
cin >> a[i];
sum += a[i];
}
//如果我们需要找到最小时间,就要要求两个机器完成时间差最小
for(int i = 0; i < 6; i++){
for(int j = 0; j < 6; j++){
for(int k = 0; k < 6; k++){
if(i == j || j == k || i == k)continue;
mm = a[i] + a[j] + a[k];
sub = sum - mm;
if(sub >= mm){
int xx = sub - mm;
if(xx < min) {
x1 = i,y1 = j,z1 = k;
min = xx;
}
}
else{
int xx = mm - sub;
if(xx < min) {
x1 = i,y1 = j,z1 = k;
min = xx;
}
}
}
}
}
cout << x1 << " " << y1 << " " << z1 << endl;
int ss = a[x1] + a[y1] + a[z1];
cout << ss << " " << sum;
return 0;
}