(Moderator — would you care to fix those two mistakes in my original reply, to tidy things up?)

]]>So overall, as others have already said, the largest possible n is 9927 (with 9+9+2+7 = 27) and the smallest is 1810 (with 1+8+1+0 = 10).

]]>I get the same answer as Leo. ]]>

a + b + c + d – 10c + d leads to the necessary condition that a + b = 9c

This fits your numbers but I cannot go any further to eliminate smaller and larger four-digit numbers.

]]>