#include <iostream> 
using namespace std; 

const int MAXN = 10*1000; 
const int MAXW = 100*1000; 

bool d[MAXW+10]; 
int p[MAXW+10]; 
int a[MAXN+10]; 

int main() 
{ 
	ios::sync_with_stdio(false); 
	int n, w; 
	cin >> n >> w; 
	for(int i=0; i<n; i++) 
		cin >> a[i]; 

	d[0] = 1; 
	for(int i=0; i<n; i++) 
		for(int j=w; j>=a[i]; j--) 
			if( d[j] == 0 && d[j-a[i]] == 1 ) 
			{ 
				d[j] = 1; 
				p[j] = a[i]; 
			} 

	int out = w; 
	for(; out>=0; out--) 
		if( d[out] ) 
			break; 

	cout << out << endl; 
	while( out != 0 ) 
	{ 
		cout << p[out] << " "; 
		out -= p[out]; 
	} 
	cout << endl; 
	return 0; 
}