// Arup Guha
// 4/4/2024
// Solution for Money Sums problem on CSES
// https://cses.fi/problemset/task/1745

import java.util.*;

public class moneysums {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int total = 0;
		int[] vals = new int[n];
		
		// Read in my coins.
		for (int i=0; i<n; i++) {
			vals[i] = stdin.nextInt();
			total += vals[i];
		}
		
		// Store which values we can make.
		boolean[] cando = new boolean[total+1];
		cando[0] = true;
		
		// Loop through coins.
		for (int i=0; i<n; i++) {
		
			// See if adding coin i allows us to get a total of value j.
			for (int j=total; j>=vals[i]; j--)
				cando[j] = cando[j] || cando[j-vals[i]];
		}
		
		// Find out # of answers.
		int numans = 0;
		for (int i=1; i<=total; i++)
			if (cando[i])
				numans++;
		
		// Output everything they want.
		System.out.println(numans);
		StringBuffer sb = new StringBuffer();
		for (int i=1; i<=total; i++)
			if (cando[i])
				sb.append(i+" ");
		System.out.println(sb);
	}
}