Find the sum of all positive integers $n$ such that when $1^3+2^3+3^3 +\dots+ n^3$ is divided by $n+5$ the remainder is $17.$ 
Find the sum of all positive integers $n$ such that when $1^3+2^3+3^3 +\dots+ n^3$ is divided by $n+5$ the remainder is $17.$

Letting $k= n+5$ we get that $1^3+2^3+3^3 +\dots+ (k-5)^3 \equiv 17 \text{ (mod $k$)}$.
Knowing the sum of cubes formula we get that ($\frac{(k-5)(k-4)}{2})^2\equiv 17 \text{ (mod $k$)}$.
From here I'm not sure how I should continue. What would be my options?

$\frac{1}{4}(k-5)^2(k-4)^2$ = $\frac{1}{4}(k^4-18k^3+121k^2-360k+400)$=$pk+17$ for some integer $p$. So, $\frac{1}{4}(k^4-18k^3+121k^2-360k+332)$ = $pk$ => $k$ should divide $332$ . So we get possible values of $k$ as $1,83,166,332$. As $k>4$, $k=1$ is not possible. Similarly for $k=332$, $(k^3-18k^2+121k-360+1)$ is clearly not divisible by $4$. So, $p=\frac{1}{4}(k^3-18k^2+121k-360+1) $ isn't an int, which is not possible. When $k=83$, it is easy to see that $p=\frac{1}{4}(k^3-18k^2+121k-360+4)$ is an integer(Why?). With a bit of clever reasoning you can verify that $k =166$ also fits the bill. So, $n= 78 \space and \space 161$.
