Help me in solving SLOWSOLN problem

Problem Link: https://www.codechef.com/problems/SLOWSOLN

@shashank0068

The logic is we can find the number of test cases using T=sumN/maxN and remaining smaller values of n  as sumN%maxN.
now if T<tmax
then answer would be T*maxN*maxN + r*r;
else
answer would be tmax*maxN*maxN;