program sume;
var n,d,s1,s2,s3, i, p :longint;
begin
write('n= '); read(n);
write('d= '); read(d);
s1:=0;
for i:=1 to n do
s1:=s1+i;
writeln('1+2+3+...+n = ',s1);
s2:=0;
for i:=0 to n-1 do
s2:=s2 + (4+i*d);
writeln('4+4+d+4+2d+4+3d+...+4+(n-1)d = ',s2);
s3:=0;
p:=1;
for i:=0 to n-1 do
begin
s3:=s3 + 5*p;
p:=p*d;
end;
writeln('5+5d+5d^2+5d^3+...+5d^(n-1) = ',s3);
end.