S = 40x41 + 41x42 + ... + 99x100
3S = 40x41x(42-39) + 41x42x(43-40) + 42x43x(44-41) + ...+ 99x100x(101-98)
3S = 40x41x42 - 39x40x41 + 41x42x43 - 40x41x42 + 42x43x44 - 41x42x43 + ...+ 99x100x101 - 98x99x100
3S = 99x100x101 - 39x40x41 = 935.940
S = 311980.