Meditation

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Luna had a stressful day and she wants to do a meditation routine that relaxes her well. Luna’s routines are more or less relaxing and to determine how relaxing a routine is, Luna computes its score: the higher the score, the more relaxing it is!

Luna has graded each of the n exercises with a positive integer and the score of a routine is simply the sum of the grades of its individual exercises. She gives you her list of graded exercises and asks you what is the maximal grade of a routine composed of k different exercises.

입력

The first line of the input contains two space-separated integers: n and k. The n following lines each contain a single integer, the i + 1-th line containing the grade gi of the i-th exercise.

출력

The output should contain a single line with a single integer: the maximal score of a routine composed of k different exercises.

제한

  • 1 ≤ k ≤ n ≤ 100 000
  • for all 1 ≤ i ≤ n, we have 0 ≤ gi ≤ 10 000

힌트

We select the exercises 1, 2 and 5 which gives a total score of 10 + 22 + 10 = 42.