n, k = map(int, input().split()) a = list(map(int, input().split())) inf = 10**9 dp = [[[-inf]*(n) for _ in range(n)] for _ in range(k+1)] for i in range(n): dp[k][i][i] = a[i] * k; ret = [-inf] * (n) #for _ in range(n):ret.append(-inf) for i in range(k,-1,-1): for j in range(n): for o in range(n): if abs(j-o) <= i:dp[i-abs(j-o)][o][j] = max(dp[i-abs(j-o)][o][j], dp[i][j][o]) if j!=o and i>=2 :dp[i-2][j][o] = max(dp[i-2][j][o], dp[i][j][o]) if j<=o and j>0 and i>0: dp[i-1][j-1][o] = max(dp[i-1][j-1][o],dp[i][j][o]+(i-1)*a[j-1]) if j>=o and j0: dp[i-1][j+1][o] = max(dp[i-1][j+1][o],dp[i][j][o]+(i-1)*a[j+1]) if j<=o and j+i<=o:ret[j+i] = max(ret[j+i], dp[i][j][o]) if j>o and j-i>=o:ret[j-i]=max(ret[j-i],dp[i][j][o]) for x in ret: print(x)