• + 0 comments

    Can anybody Suggest what is the mistake in my code I belive the logic is correct :

    def subarray(A):
        start = next(x for x, val in enumerate(A) if val > 0) 
        end = next(n-x for x, val in enumerate(A[n:0:-1]) 
                                      if val > 0 )            
        largestValue(Arr=A[start:end])    
    def largestValue(Arr):         
        Sum=sum(Arr)
        result=0    
        #print(Arr,l)
        for i in range(len(Arr)-1):
            Sum-=Arr[i]
            result+=Arr[i] * (Sum)       
        print(result)    
    n = int(input())
    
    A = list(map(int, input().rstrip().split()))
    subarray(A)