Let
K=2n(n+1), so the sum of cubes is
K2. Modulo
n+5 we have
n≡−5, hence
2K=n(n+1) ≡(−5)(−4)=20 and
4K2≡400. If
K2≡17(modn+5), then
n+5 divides
400−4⋅17=332=22⋅83. Since a remainder of
17 also forces
n+5>17, the candidates are
n+5∈{83,166,332}, i.e.
n∈{78,161,327}.
Because we multiplied by
4, each candidate must be checked. For
n=78: K=3081≡10(mod83), and
102=100≡17(mod83). For
n=161: K=13041≡93(mod166), and
932=8649=52⋅166+17. For
n=327: K=53628≡176(mod332), and
1762=30976=93⋅332+100, remainder
100=17, so this one fails.
The valid values are
n=78 and
n=161, with sum
78+161=239.