#include <bits/stdc++.h>
using namespace std;
int a[1000 + 20];
int cnt;
void up(int p) {
while (p != 1) {
if (a[p / 2] >= a[p]) {
swap(a[p], a[p / 2]);
p /= 2;
} else
break;
}
}
void inser(int n) {
a[++cnt] = n;
up(cnt);
}
void down(int p) {
while (1) {
if (p * 2 + 1 <= cnt) {
if (a[p * 2] <= a[p * 2 + 1]) {
a[p] = a[p * 2];
p = p * 2;
} else {
a[p] = a[p * 2 + 1];
p = p * 2 + 1;
}
}
else {
a[p] = a[cnt];
up(p);
return;
}
}
}
void pop() {
down(1);
cnt--;
}
int b[3020];
int main() {
int n, m;
while (scanf("%d %d", &n, &m) != EOF) {
cnt = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", b + i);
}
for (int i = 1; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
if (cnt < m) {
inser(b[i] + b[j]);
} else if (b[i] + b[j] > a[1]) {
pop();
inser(b[i] + b[j]);
}
}
}
int ans[1020];
for (int i = 1; i <= m; i++) {
ans[i] = a[1];
pop();
}
for (int i = m; i >= 1; i--) {
printf("%d", ans[i]);
if (i != 1) printf(" ");
}
printf("\n");
}
return 0;
}