N, K = gets.chomp.split.map(&:to_i) As = gets.chomp.split.map(&:to_i) puts As.select { _1.positive? }.sort.reverse.take(K).sum