_, K = gets.split.map(&:to_i) A = gets.split.map(&:to_i) puts A.sort_by(&:-@).reject(&:negative?).take(K).inject(:+)