using namespace std;
#include<iostream>
#include<cmath>
#include<set>
int * binary;
void generateBinary(int, int);
int main(void)
{
int n;
cin >> n;
int weight[n];
int sum = 0;
for(int i=0; i<n; i++)
{
cin >> weight[i];
sum += weight[i]; /* Calculated maximum sum of weights here */
}
int index = 2 * n;
binary = new int[index];
/* An array of twice the number of weights, half the bits indicate presence or absence of weight
another half bits indicate whether the weight is to be added or subtracted
*/
int max = pow(2, index)-1; /* Maximum number of combinations of weights and +- signs */
set <int> s;
set <int>::iterator it;
for(int i=max; i>0; i--)
{
generateBinary(i, index);
/* For all weights from max to 1, generate binary sequence
First bit for + or - sign; if 1: +, if 0: -
Next bit will be set fot the weight; 1: included, 0: not included
*/
int localsum = 0;
for(int j=1; j<index; j+=2)
{
if(binary[j] == 1) /*If the bit is 1, I have to include this weight */
{
if(binary[j-1] == 1) /* If the previous bit is 1, I have to add the weight */
localsum += weight[j/2];
else
localsum -= weight[j/2]; /* If the previous bit is 0, I have to subtract the weight */
}
}
if(localsum > 0)
{
s.insert(localsum); /* If sum is positive, insert it into the set */
}
}
for(it=s.begin(); it!=s.end(); it++)
cout << *it << " ";
cout << endl;
delete [] binary;
}
void generateBinary(int n, int bits)
{
for(int i=bits-1; i>=0; i--)
{
int k = n >> i;
if(k & 1)
binary[bits-i-1] = 1;
else
binary[bits-i-1] = 0;
}
}