program TinhTongChiaHetChoBa;
var
N, i, Tong: integer;
begin
writeln('Nhap so nguyen duong N (3 <= N <= 50):');
readln(N);
if (N < 3) or (N > 50) then
begin
writeln('N khong hop le!');
readln;
exit;
end;
Tong := 0;
i := 3;
while i <= N do
begin
if i mod 3 = 0 then
begin
Tong := Tong + i;
end;
i := i + 1;
end;
writeln('Tong cac so tu 3 den ', N, ' chia het cho 3 la: ', Tong);
readln;
end.