program TongCacSoChiaHetChoBa;
var
n, i, sum: integer;
begin
repeat
Write('Nhap so nguyen n (3 <= n <= 50): ');
Readln(n);
until (n >= 3) and (n <= 50);
sum := 0;
for i := 3 to n do
begin
if i mod 3 = 0 then
sum := sum + i;
end;
WriteLn('Tong cac so chia het cho 3 trong khoang tu 3 den ', n, ': ', sum);
ReadLn;
end.