Jewelry Store

With unlimited gems of each of N kinds, list all total values obtainable by choosing exactly K gems.

Medium5Dynamic programmingCombinatoricsInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

A thief broke into a jewelry store. The thief wants to carry off exactly KK gems.

The store stocks NN kinds of gems. Gems of kind ii are worth aia_i each, and every kind is available in unlimited supply.

Write a program that finds every total value the thief can carry off.

Input

The first line contains NN and KK. (1N,K10001 \le N, K \le 1000)

The second line contains a1,a2,,aNa_1, a_2, \dots, a_N separated by spaces. (1ai10001 \le a_i \le 1000) The same value may appear more than once.

Output

Print every reachable total value on one line in ascending order. Separate two consecutive totals with a single space. Print each total only once.