def main(str)
  lines = str.split("\n")
  _, k = lines[0].split(" ").map(&:to_i)
  ps = lines[1].split(" ").map(&:to_i)
  ps.sort[0...k].sum.to_s
end

unless ENV["TEST"]
  main($stdin.read.chomp)
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("210", main("5 3
50 100 80 120 80"))
    # assert_equal("", main(""))
  end
end


