n,k = map(int,input().split()) an = sorted(list(map(int,input().split())))[::-1] count = an[0] for i in range(1,len(an)): if an[i]<0:break else:count+=an[i] print(count)