#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void f(int i, vector<int> &v, vector<int> &ans){
while(i<v.size()){
for(int x: ans) cout<<x<<'\t';
cout<<v[i]<<endl;
ans.push_back(v[i]);
f(++i, v, ans);
ans.pop_back();
}
}
int main() {
int n,x;
vector<int> v;
cin>>n;
while(n--&&cin>>x) v.push_back(x);
sort(v.begin(),v.end());
vector<int> rec_temp;
f(0,v,rec_temp); // recursive approach
return 0;
// iterative approach
vector<vector<int>> ans;
vector<int> temp;
n = v.size();
for(int i=n-1; i>=0; i--){
x = ans.size();
for(int j=0; j<x; j++){
temp = vector<int>(1,v[i]); // array containing single element v[i]
temp.insert(temp.end(),ans[j].begin(),ans[j].end());
ans.push_back(temp);
}
temp = vector<int>(1,v[i]);
ans.push_back(temp);
}
ans.push_back(vector<int>(0));
x = ans.size();
for(int i=x-1; i>=0; i--){
for(int j=0; j<ans[i].size(); j++) cout<<ans[i][j]<<'\t';
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp2b2lkIGYoaW50IGksIHZlY3RvcjxpbnQ+ICZ2LCB2ZWN0b3I8aW50PiAmYW5zKXsKCXdoaWxlKGk8di5zaXplKCkpewoJCWZvcihpbnQgeDogYW5zKQljb3V0PDx4PDwnXHQnOwoJCWNvdXQ8PHZbaV08PGVuZGw7CgkJYW5zLnB1c2hfYmFjayh2W2ldKTsKCQlmKCsraSwgdiwgYW5zKTsKCQlhbnMucG9wX2JhY2soKTsKCX0KfQppbnQgbWFpbigpIHsKCWludCBuLHg7Cgl2ZWN0b3I8aW50PiB2OwoJY2luPj5uOwoJd2hpbGUobi0tJiZjaW4+PngpCXYucHVzaF9iYWNrKHgpOwoJc29ydCh2LmJlZ2luKCksdi5lbmQoKSk7Cgl2ZWN0b3I8aW50PiByZWNfdGVtcDsKCWYoMCx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