CONST
	MaxN = 100010;
	MaxDivNum = 1010;

VAR
        inFile, outFile : TEXT;
	a, b : array[0..MaxN] of longint;
	divisors : array[0..MaxDivNum] of longint;
	n, k, s, divNum, groupCount, sol, i, j : longint;

BEGIN

	assign(inFile, 'nzd.in');
	assign(outFile, 'nzd.out');
	reset(inFile); rewrite(outFile);

	read(inFile, n, k);
	s := 0;
	for i := 1 to n do begin
		read(inFile, a[i]);
		s := s + a[i];
	end;

	divNum := 0;
	for i := 1 to s - 1 do
		if ((s MOD i) = 0) then begin
			divNum := divNum + 1;
			divisors[divNum] := i;
		end;
	
	for j := divNum downto 1 do begin
	
		sol := divisors[j];
		groupCount := 0;
		for i := 1 to n do b[i] := 0;
		
		for i := 1 to n do begin
			b[groupCount + 1] := b[groupCount + 1] + a[i];
			if ((b[groupCount + 1] MOD sol) = 0) then
				groupCount := groupCount + 1;
		end;
	
		if (groupCount >= k) then break;
	
	end;

	for i := k + 1 to groupCount do
		b[k] := b[k] + b[i];

	writeln(outFile, sol);
	for i := 1 to k - 1 do
		write(outFile, b[i], ' ');
	writeln(outFile, b[k]);

	close(inFile);
	close(outFile);

END.
