n = 31q +13
31q +13 ≥ 100 31q ≥ 87 q ≥ 3
31q + 13 ≤ 999 31q ≤ 986 q ≤ 31
⇒ n∈ {106,137,168,.........974}
S = (31·3 + 13) + (31·4 +13) + (31·5 +13) +............+(31·31 +13) =
= 13·29 + 31(3 + 4 + 5 +....+31) = 899 +31·[ 31·32/2 - (1+2)] = 899 + 31·493 =
= 16182