Negative Sum

Description:

Write a program to find the sum of negative numbers Input:Positive and negative numbers Output:Display Sum of negative numbers Refer sample input and output for formatting specification. Test Case 1 Input (stdin) 7 10 -10 -43 -45 46 30 31 Expected Output Sum of negative numbers: -98 Test Case 2 Input (stdin) 5 10 -10 -43 -45 -46 Expected Output Sum of negative numbers: -144

Program :


n=int(input(""))

b=[]

for i in range(0,n):

    a=int(input(""))

    b.append(a)

sum1=0

sum2=0

sum3=0

for j in b:

    if(j>0):

        if(j%2==0):

            sum1=sum1+j

        else:

            sum2=sum2+j

    else:

        sum3=sum3+j

print("Sum of negative numbers:",sum3)