#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
std::vector<int> numbers;
int n, m;
int number;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> number;
numbers.push_back(number);
}
sort(numbers.begin(), numbers.end());
for (int i = 0; i < m; i++) {
int sum = numbers[n-1];
int k = n - 2;
if (!(float(sum) / (i + 2) <= numbers[k] && k >= 0)) {
//cout << sum << " " << k+1 << " " << i << endl;
}
while (float(sum) / (i+(n-k)) <= numbers[k] && k>=0) {
//cout << sum << " " << k<<" "<<i << endl;
sum += numbers[k];
k--;
}
float mean = float(sum) / (i + (n - k));
//cout << "div " << i + (n - k) << endl;
int numOfSplits = n-1 - k;
//std::cout << "num of splits " << numOfSplits << endl;
k++;
//std::cout << "k " << numbers[k] << endl;
//std::cout << "mean " << mean << endl;
std::vector<int> splittingNumbers;
std::vector<float> splittingSize;
int sumOfSplittingNums=0;
for (int j = n - 1; j >= k; j--) {
//std::cout << "j " << j << endl;
int splitNum = (numOfSplits) * float(numbers[j]) / sum;
//cout << "splitNm " << splitNum<<" "<< float(numbers[j]) / (splitNum+1) << endl;
sumOfSplittingNums += splitNum;
splittingNumbers.push_back(splitNum);
if (splitNum != 0) {
splittingSize.push_back(float(numbers[j]) / (splitNum+1));
}
}
int dif = numOfSplits - sumOfSplittingNums;
//std::cout << "dif " << dif << endl;
while (dif > 0) {
int max=0;
int index=0;
for (int t = 0; t < splittingSize.size(); t++) {
if (max < splittingSize[t]) {
max = splittingSize[t];
index = t;
}
}
//std::cout << "index " << index<<" "<<splittingNumbers[index] << " " << n - 1 - index << endl;
splittingNumbers[index]+=1;
splittingSize[index] = float(numbers[n-1-index]) / (1+splittingNumbers[index]);
//std::cout << "splits left "<<dif<<" " << splittingSize[index] << endl;
dif--;
}
int max = 0;
int min = 999999;
for (int t = 0; t < splittingSize.size(); t++) {
//std::cout << "splitSize "<<t<<" " << splittingSize[t] << endl;
if (max < ceil(splittingSize[t])) {
max = ceil(splittingSize[t]);
}
if (min > floor(splittingSize[t])) {
min = floor(splittingSize[t]);
}
}
for (int t = n-1-splittingSize.size(); t >= 0; t--) {
if (max < numbers[t]) {
max = numbers[t];
}
if (min > numbers[t]) {
min = numbers[t];
}
//std::cout << "min check " << numbers[t] << " " << min << endl;
}
//std::cout << "abs diff " << max - min<<" "<<max<<" "<<min << endl;
//cout << endl;
std::cout << max - min << " ";
}
return 1;
}