#include <bits/stdc++.h>
using namespace std;
ifstream fin ("economie.in");
ofstream fout ("economie.out");
const int N_MAX = 5e4 + 5;
int n;
int a[N_MAX], dp[N_MAX];
vector<int>used, v;
int main(){
ios_base::sync_with_stdio(false);
fin >> n;
for (int i = 1; i <= n; i++){
fin >> a[i];
}
sort(a + 1, a + n + 1);
dp[0] = true;
for (int i = 1; i <= n; i++){
if (!dp[a[i]]){
used.push_back(a[i]);
for (int j = a[i]; j < N_MAX; j++){
dp[j] |= dp[j - a[i]];
}
}
}
fout << (int)used.size() << '\n';
for (int x : used){
fout << x << '\n';
}
}