5943: 出售

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:7 通过:4

题目描述

        有一次鲍勃参加了旧电视机的出售会。那次销售中有n台电视机。编号为i的电视机价格为ai。有些电视机的价格为负——如果鲍勃购买了他们无用的设备,它们的主人愿意付钱给鲍勃。鲍勃可以“购买”他想要的任何电视机。虽然他很强壮,但鲍勃最多可以携带 m 台电视机,而且他不想第二次去销售。请帮助鲍勃找出他可以赚到的最大金额。
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price − their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he has no desire to go to the sale for the second time. Please, help Bob find out the maximum sum of money that he can earn.
Input
The first line contains two space-separated integers n and m (1≤mn≤100) − amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (-1000≤ai≤1000) − prices of the TV sets.
Output
Output the only number − the maximum sum of money that Bob can earn, given that he can carry at most m TV sets.
Examples
Input
5 3
-6 0 35 -2 4
Output
8
Input
4 2
7 0 0 -7
Output
7 

输入格式

第一行包含两个空格分隔的整数 n 和 m (1≤m≤n≤100) − 销售中的电视机数量,以及鲍勃可以携带的电视机数量。第二行包含 n 个空格分隔的整数 ai (-1000≤ai≤1000) − 电视机的价格。

输出格式

输出唯一的数字 - 鲍勃可以赚到的最大金额,因为他最多可以携带 m 台电视机。
输入样例1:
5 3
-6 0 35 -2 4
输出样例1:
8
输入样例2:
4 2
7 0 0 -7
输出样例2:
7

输入样例 复制

5 3
-6 0 35 -2 4

输出样例 复制

8