#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, n2;
vector<vector<int>> result;
void dfs(vector<int> d, int idx, int sm, int mx, vector<int> temp, int num){
temp.push_back(num);
if (temp.size() == n){
sort(temp.begin(), temp.end());
vector<int> t;
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
t.push_back(temp[j]-temp[i]);
}
}
sort(t.begin(), t.end());
bool bad = 1;
for (int i = 0; i < n2; i++){
if (d[i] != t[i]) {
bad = 0;
break;
}
}
if (bad) result.push_back(temp);
return;
}
int l = d[idx]-sm, r = mx-d[idx];
for (int i = 0; i <= idx; i++){
if (d[i] == l){
dfs(d, idx-1, sm, mx, temp, l);
}
if (d[i] == r){
dfs(d, idx-1, sm, mx, temp, r);
}
}
}
int main(){
cin >> n;
n2 = n*(n-1)/2;
vector<int> d(n2);
for (int i = 0; i < n2; i++){
cin >> d[i];
}
int mx = d[n2-1];
vector<int> temp = {0};
dfs(d, n2-2, 0, mx, temp, mx);
sort(result.begin(), result.end());
// for (int i = 0; i < result.size(); i++){
// for (int j : result[i]) cout << j << " ";
// cout << "\n";
// }
for (int i : result[0]) cout << i << " ";
cout << "\n";
for (int i : result[result.size()-1]) cout << i << " ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBuLCBuMjsKdmVjdG9yPHZlY3RvcjxpbnQ+PiByZXN1bHQ7Cgp2b2lkIGRmcyh2ZWN0b3I8aW50PiBkLCBpbnQgaWR4LCBpbnQgc20sIGludCBteCwgdmVjdG9yPGludD4gdGVtcCwgaW50IG51bSl7CiAgICB0ZW1wLnB1c2hfYmFjayhudW0pOwogICAgaWYgKHRlbXAuc2l6ZSgpID09IG4pewogICAgICAgIHNvcnQodGVtcC5iZWdpbigpLCB0ZW1wLmVuZCgpKTsKICAgICAgICB2ZWN0b3I8aW50PiB0OwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IGkgKyAxOyBqIDwgbjsgaisrKXsKICAgICAgICAgICAgICAgIHQucHVzaF9iYWNrKHRlbXBbal0tdGVtcFtpXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgc29ydCh0LmJlZ2luKCksIHQuZW5kKCkpOwogICAgICAgIGJvb2wgYmFkID0gMTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG4yOyBpKyspewogICAgICAgICAgICBpZiAoZFtpXSAhPSB0W2ldKSB7CiAgICAgICAgICAgICAgICBiYWQgPSAwOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGJhZCkgcmVzdWx0LnB1c2hfYmFjayh0ZW1wKTsKICAgICAgICByZXR1cm47CiAgICB9CgogICAgaW50IGwgPSBkW2lkeF0tc20sIHIgPSBteC1kW2lkeF07CiAgICBmb3IgKGludCBpID0gMDsgaSA8PSBpZHg7IGkrKyl7CiAgICAgICAgaWYgKGRbaV0gPT0gbCl7CiAgICAgICAgICAgIGRmcyhkLCBpZHgtMSwgc20sIG14LCB0ZW1wLCBsKTsKICAgICAgICB9CiAgICAgICAgaWYgKGRbaV0gPT0gcil7CiAgICAgICAgICAgIGRmcyhkLCBpZHgtMSwgc20sIG14LCB0ZW1wLCByKTsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKCl7CiAgICBjaW4gPj4gbjsKICAgIG4yID0gbioobi0xKS8yOwogICAgdmVjdG9yPGludD4gZChuMik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG4yOyBpKyspewogICAgICAgIGNpbiA+PiBkW2ldOwogICAgfQogICAgaW50IG14ID0gZFtuMi0xXTsKICAgIHZlY3RvcjxpbnQ+IHRlbXAgPSB7MH07CiAgICBkZnMoZCwgbjItMiwgMCwgbXgsIHRlbXAsIG14KT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