Classical dp problem

im using python language…and problem link is

and i apply dp technique and its complexity is O(n)…
but my solution is giving TLE due to may be list concatenation…is using python for competitive programming is bad…can anyone tell plz how to fix this problem…

and my solution link is

You can’t concatenate k copies of n in any language.
k<10^5 \& n<10^5 so kn<10^{10}

What logic have to apply to form k copies??without naive approach is there any efficient approach???

A few cases.
If k=1, do the normal kadane algorithm.
Else,
If sum>0
Find minimum prefix and suffix,
and subtract from sum*k
Else
Concatenate the sequence once, and run kadane’s