시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 2 2 2 100.000%

문제

You are given a bag of N integers, and you are to put these integers into M distinct groups. When you distribute the integers, you have to make sure that each integer belongs to exactly one group and the size of any two different groups differs by at most 1.

The cost of a group is equal to the lowest integer in that group, while the total cost of M groups simply equals to the summation of the cost of each group. Note that the cost of an empty group is zero.

Now, your task in this problem is to find a way to put N given integers (not necessarily unique) into M distinct groups such that the total cost of those groups is minimum. Also, find a way such that the total cost is maximum. Output only the total costs.

입력

Input begins with two integers: N M (1 ≤ N, M ≤ 100000) representing the number of given integers and the number of groups to be made, respectively. The next line contains N integers: Ai (0 ≤ Ai ≤ 1000000) representing the given integers.

출력

Output in a line two integers (separated by a single space) representing the minimum total cost and the maximum total cost, respectively.

예제 입력 1

7 3
4 2 7 1 3 5 6


예제 출력 1

6 11


The minimum total cost can be obtained from {(6, 3, 5),(4, 1),(2, 7)} with a total cost of 3 + 1 + 2 = 6.

The maximum total cost can be obtained from {(4, 5),(7, 6),(2, 1, 3)} with a total cost of 4 + 6 + 1 = 11.

예제 입력 2

5 1
10 15 17 4 8


예제 출력 2

4 4


예제 입력 3

3 2
470 105 222


예제 출력 3

327 575