fork(1) download
  1. N, K = map(int, input().split())
  2. arr = list(map(int, input().split()))
  3. arr.sort()
  4. sum_k = sum(arr[:K])
  5. print(*arr, sum_k)
Success #stdin #stdout 0.11s 14064KB
stdin
8 3
10 20 30 45 31 42 12 16
stdout
10 12 16 20 30 31 42 45 38