program bb;
uses crt;
const n=30;
var
m:array[1..n]of integer;
i,k,s:integer;
begin
clrscr;
randomize;
for i:=1 to n do
begin
m[i]:=i;
write(m[i],' ');
end;
writeln;
write('K = ');
read(k);
writeln;
s:=0;
for i:=1 to n do
if m[i] mod k = 0 then
begin
s:=s+m[i];
write(m[i],' ');
end;
writeln;
writeln;
writeln('Сумма элементов кратных данному К = ',s);
end.