#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+2) <= numbers[k] && k>=0) {
cout << sum << " " << k<<" "<<i << endl;
sum += numbers[k];
k--;
}
k++;
float mean = float(sum) / (i + 2);
std::cout << "k " << numbers[k] << endl;
if (floor(mean) == numbers[k]) {
std::cout <<"f "<<mean<<" "<<numbers[k]<<" " << floor(mean) - numbers[0] << endl;
}
else {
if (mean>numbers[0]){
}
std::cout << ceil(mean) - numbers[0] << endl;
}
//std::cout << float(sum) / (i + 2) << endl;
}
return 1;
}