https://www.codechef.com/KPM22019/problems/KETEKI2A

https://www.codechef.com/KPM22019/problems/KETEKI2A
can someone please point out to me whats wrong with code .

lens = int(input())
arrs = [int(x) for x in input().split()]
petu,ketu = 0, 0
while len(arrs) > 0:
    petu += arrs.pop(0)
    if len(arrs)>0:
        ketu += arrs.pop()
print(abs(petu - ketu))

What I had done is
While there is a value petu point is incrementred with pop(0),if still there is something ketu’s point is incremented with pop.
This process continues till array is empty.
Abs value of petu - ketu should be the answer.
But this is failing on some cases and i would like to know why

Because answer should not be absolute . It should be just difference!

1st issue is that you have returned the absolute value which was not required (I did the same mistake)

Recommendation : you can improve the code by finding the ceil of mid and slice the array into two halves, then find the sum and return the reqd difference