program Day_Max;
const
MAXN = 1000;
var
n, k, i, j, len, maxLen, startIdx: integer;
a: array[1..MAXN] of integer;
procedure ReadInput;
var
inputFile: text;
begin
assign(inputFile, 'DAYCON.INP');
reset(inputFile);
readln(inputFile, n, k);
for i := 1 to n do
read(inputFile, a[i]);
close(inputFile);
end;
procedure WriteOutput(len, startIdx: integer);
var
outputFile: text;
begin
assign(outputFile, 'DAYCON.OUT');
rewrite(outputFile);
writeln(outputFile, len);
for i := startIdx to startIdx + len - 1 do
write(outputFile, i, ' ');
close(outputFile);
end;
function Day_max: integer;
var
sum: array[1..MAXN] of integer;
begin
sum[0] := 0;
for i := 1 to n do
sum[i] := (sum[i - 1] + a[i]) mod k;
maxLen := 0;
startIdx := -1;
for i := 1 to n do
for j := i downto 1 do
begin
len := i - j + 1;
if (len > maxLen) and ((sum[i] - sum[j - 1] + k) mod k = 0) then
begin
maxLen := len;
startIdx := j;
end;
end;
Result := maxLen;
end;
begin
ReadInput;
WriteOutput(Day_max, startIdx);
end.