#include
#include
using namespace std;
//problem: considering one number for only one combination
bool sum_it_up(vectorv, vectorans, int i, int sum, int k){
if(k>sum || i==v.size()){
return false;
}
if(k==sum){
//print the ans vector
for(auto x:ans){
cout<<x<<" ";
}
cout<<endl;
//since we need all the combinations
return true;
}
//recursive call for considering numbers
for(int number=i; number<v.size(); number++){
//consider we can take this number and its ok
ans.push_back(v[number]);
bool sum_lies_ahead= sum_it_up(v,ans,number+1,sum,k+v[number]);
if(sum_lies_ahead==true){
return true;
}
ans.pop_back(); //backtrack,if not
}
return false;
}
int main(){
vector<int>v;
int n;
cin>>n;
for(int i=0; i<n; i++){
int no;
cin>>no;
v.push_back(no);
}
vector<int>ans;
sum_it_up(v,ans,0,6,0);
return 0;
}



