## Problem: Mega SALE

LALU wanted to purchase a laptop so he went to a nearby sale.There were

Laptops at a sale. Laptop with indexncostsirupees. Some Laptops have a negative price — their owners are ready to pay LALU if he buys their useless Laptop. LALU can buy any Laptop he wants. Though he’s very strong, he can carry at mosta_{i}Laptops, and he has no desire to go to the sale for the second time. Please, help LALU find out the maximum sum of money that he can earn.m

Input:First line of the input contains

Tdenoting the number of test cases.Each test case has 2 lines :

- first line has two spaced integers n m.
- second line has n integers [a
_{0}…a_{i}…a_{n-1}].

Output:The maximum sum of money that LALU can earn, given that he can carry at most

mLaptops.

Constraints:1≤

T≤101≤

n,m≤100-1000≤

a≤1000_{i}

Sample Input:1

5 3

-6 0 35 -2 4

Sample Output:8

Explanation:LALU takes the laptops with -6 and -2 and thus earns 8 rupees.

Python 2.7

t = input() for _ in range(t): n, m = [int(x) for x in raw_input().strip().split()] laptops = [int(x) for x in raw_input().strip().split()] laptops.sort() earn, amount = 0, 0 for _ in laptops: if _ <= 0: earn += _ amount += 1 if amount == m: break else: break print earn*-1

## Reply