Can't figure out the stopping condition

i am trying to use a for loop like:
while(condition)
{ i=i%n;
kadane algorithm
++i; }

But i can’t think of an appropriate stopping condition pls help

Consider this testcase
1
3
10 -3 3
ans should be 13 but your code is giving 10.
use sliding window technique to solve this question. Take reference from gfg