Równowaga taśmy

//Time complexity of 100% and correctness of 100%
def solution(A):
    total = 0
    left_total = 0
    right_total = 0
    if len(A) == 0:
        return 0
    elif len(A) == 1:
        return A[0]

    for x in range(1,len(A)):
        left_total += A[x-1]

        if x == 1:
            right_total = sum(A[x:])
        else:
            right_total -= A[x-1]

        mySum =abs(right_total-left_total)

        if x == 1 or total > mySum:
            total = mySum

    return total
Headache reliver