using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    public static void Main(string[] args)
    {
        PushTestData(@"
3
0 0 0
0 0 0

4
0 0 2 0
1 1 1 1

5
0 0 1 1 2
2 0 1 0 0

YES
1 3 1 2 1
");
        var n = RI();
        var l = RIA(n);
        var r = RIA(n);
        var ans = new int[n];

        int next = n + 1;
        int total = 0;
        var m = new HashSet<int>();
        while(true)
        {
            m.Clear();
            for (int i = 0; i < n; i++)
            {
                if (ans[i] == 0 && (l[i] + r[i]) == 0)
                {
                    m.Add(i);
                }
            }

            if (m.Count == 0)
            {
                Console.WriteLine("NO");
                return;
            }

            total += m.Count;
            next--;
            foreach (var j in m) ans[j] = next;

            foreach (var j in m)
            {
                for (int k = 0; k < j; k++)
                    if (ans[k] == 0)
                    {
                        r[k]--;
                        if (r[k] < 0)
                        {
                            Console.WriteLine("NO");
                            return;
                        }
                    }

                for (int k = j + 1; k < n; k++)
                    if (ans[k] == 0)
                    {
                        l[k]--;
                        if (l[k] < 0)
                        {
                            Console.WriteLine("NO");
                            return;
                        }
                    }
            }

            if (total == n) break;
        }

        Console.WriteLine("YES");
        Console.WriteLine(string.Join(" ", ans));
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

    private static int GCD(int a, int b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static List<int>[] ReadTree(int n)
    {
        return ReadGraph(n, n - 1);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Length;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}


n = input()
ll = map(int, raw_input().split(" "))
lr = map(int, raw_input().split(" "))

check = False

for i in xrange(n):
    if ll[i] > i:
        check = True
        break

for i in xrange(n-1, -1, -1):
    if lr[i] > (n-1) - i:
        check = True
        break

if check:
    print "NO"
else:
    rr = [[i, ll[i], lr[i], -1] for i in xrange(n)]
    rr.sort(key=lambda x: -(x[1]+x[2]))

    rr[0][3] = 1
    for i in xrange(1, n):
        if rr[i][1] + rr[i][2] == rr[i-1][1] + rr[i-1][2]:
            rr[i][3] = rr[i-1][3]
        else:
            rr[i][3] = rr[i-1][3] + 1

    rr.sort(key=lambda x: x[0])
    res = map(lambda x: x[3], rr)
    check = False

    for i in xrange(n):
        lc, rc = 0, 0
        for j in xrange(i):
            if res[j] > res[i]:
                lc += 1

        for j in xrange(i+1, n):
            if res[j] > res[i]:
                rc += 1

        if ll[i] != lc or lr[i] != rc:
            print "NO"
            check = True
            break

    if not check:
        print "YES"
        print ' '.join(map(str, res))


n = input()
ll = map(int, raw_input().split(" "))
lr = map(int, raw_input().split(" "))

check = False

for i in xrange(n):
    if ll[i] > i:
        check = True
        break

for i in xrange(n-1, -1, -1):
    if lr[i] > (n-1) - i:
        check = True
        break

if check:
    print "NO"
else:
    rr = [[i, ll[i], lr[i], -1] for i in xrange(n)]
    rr.sort(key=lambda x: -(x[1]+x[2]))

    rr[0][3] = 1
    for i in xrange(1, n):
        if rr[i][1] + rr[i][2] == rr[i-1][1] + rr[i-1][2]:
            rr[i][3] = rr[i-1][3]
        else:
            rr[i][3] = rr[i-1][3] + 1

    rr.sort(key=lambda x: x[0])

    print "YES"
    print ' '.join(map(lambda x: str(x[3]), rr))


n=input()
l=map(int,raw_input().split())
r=map(int,raw_input().split())
temp=[n-l[i]-r[i] for i in xrange(n)]
s=[l[i]+r[i] for i in xrange(n)]
if l[0]!=0 or r[-1]!=0:
    print "NO"
elif max(s)>n-1:
    print "NO"
else:
    for i in xrange(n):
        l1=0
        r1=0
        for j in xrange(i):
            if temp[j]>temp[i]:
                l1+=1
        for j in xrange(i+1,n):
            if temp[j]>temp[i]:
                r1+=1
        if l1!=l[i] or r1!=r[i]:
            print "NO"
            break
    else:
        print "YES"
        for i in temp:
            print i,
        print


n = int(raw_input())
l = map(int,raw_input().split())
r = map(int,raw_input().split())

out = [0]*n
count = n
while count != 0:
    delete = []
    for j in range(n):
        if l[j] == 0 and r[j] == 0 and out[j] == 0:
            out[j] = str(count)
            delete.append(j)
    if len(delete) == 0:
        print "NO"
        break
    count -= len(delete)
    if count == 0:
        print "YES"
        print " ".join(out)
    for d in delete:
        for i in range(0,d):
            r[i] -= 1
        for i in range(d+1,n):
            l[i] -= 1
        r[d],l[d] = 2*n, 2*n


import sys
n=int(input())
l=list(map(int,raw_input().split()))
r=list(map(int,raw_input().split()))
p=r[::-1]
ans=[0]*n
for i in xrange(len(l)):
    if l[i]>i or p[i]>i:
        print"NO"
        sys.exit()
for i in xrange(len(l)):
    u=l[i]+r[i]
    if n-u==0:
        print"NO"
        sys.exit()
    else:
        ans[i]=n-u
print"YES"
for i in ans:
    print i,


import sys
n=int(input())
l=list(map(int,raw_input().split()))
r=list(map(int,raw_input().split()))
if l[0]!=0 or r[-1]!=0:
    print"NO"
    sys.exit()
ans=[0]*n
for i in xrange(len(l)):
    u=l[i]+r[i]
    ans[i]=n-u
print"YES"
for i in ans:
    print i,


import sys
n=int(input())
l=list(map(int,raw_input().split()))
r=list(map(int,raw_input().split()))
if l[0]!=0 or r[-1]!=0:
    print"NO"
    sys.exit()
ans=[0]*n
for i in xrange(len(l)):
    u=l[i]+r[i]
    ans[i]=1000-u
print"YES"
for i in ans:
    print i,


import sys
n=int(input())
l=list(map(int,raw_input().split()))
r=list(map(int,raw_input().split()))
p=r[::-1]
ans=[0]*n
for i in xrange(len(l)):
    if l[i]>i or p[i]>i:
        print"NO"
        sys.exit()
    else:
        u=l[i]+r[i]
        if n-u==0:
            print"NO"
            sys.exit()
        else:
            ans[i]=n-u
for i in xrange(len(ans)):
    count=0
    for j in xrange(0,i):
        if ans[j]>ans[i]:
            count+=1
    if count!=l[i]:
        print"NO"
        sys.exit()
for i in xrange(len(ans)):
    count=0
    for j in xrange(i+1,len(ans)):
        if ans[j]>ans[i]:
            count+=1
    if count!=r[i]:
        print"NO"
        sys.exit()
print"YES"
for i in ans:
    print i,


import sys
n=int(input())
l=list(map(int,raw_input().split()))
r=list(map(int,raw_input().split()))
if l[0]!=0 or r[-1]!=0:
    print"NO"
    sys.exit()
ans=[0]*n
for i in xrange(len(l)):
    u=l[i]+r[i]
    ans[i]=1000-u
print"YES"
print ans


n = input()
l = map(int, raw_input().split())
r = map(int, raw_input().split())

mp = {i:i for i in range(n)}
out = [-1]*n
v = 0

a = n
done = set()
while v < n:
    ids = set()
    for j in range(n):
        if l[j] == r[j] == 0 and j not in done:
            ids.add(j)
            done.add(j)
    if len(ids) == 0:
        print('NO')
        exit()
    v += len(ids)
    for i in ids:
        out[mp[i]] = a
        for j in range(len(l)):
            if j < i:
                r[j] -= 1
            else:
                l[j] -= 1
    a -= 1
print('YES')
print(' '.join(map(str, out)))


n=input()
left=map(int,raw_input().split())
right=map(int,raw_input().split())
ans=[]
for i in range(0,n):
    ans.append(n-left[i]-right[i])
def checker(ans):
    for i in range(0,n):
        c1=0
        c2=0
        for j in range(0,i):
            if ans[j]>ans[i]:
                c1=c1+1
        for j in range(i+1,n):
            if ans[j]>ans[i]:
                c2=c2+1
        if c1!=left[i] or c2!=right[i]:
            return 0
    return 1
if checker(ans):
    print "YES"
    for i in ans:
        print i,
else:
    print "NO"


#import resource
#import sys
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
#sys.setrecursionlimit(0x1000000)
from sys import stdin, stdout
mod=(10**9)+7
mod1=mod-1
def modinv(n,p):
    return pow(n,p-2,p)
fact=[1]
for i in range(1,100001):
    fact.append((fact[-1]*i)%mod)
def ncr(n,r,p):
    t=((fact[n])*(modinv(fact[r],p)%p)*(modinv(fact[n-r],p)%p))%p
    return t
def GCD(x, y):
   while(y):
       x, y = y, x % y
   return x
def BS(arr, l, r, x):
    if r >= l:
        mid = l + (r - l)/2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return BS(arr, l, mid-1, x)
        else:
            return BS(arr, mid+1, r, x)
    else:n -1
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import math
import heapq
from random import randint as rn
from Queue import Queue as Q
def comp(x,y):
    if(x[0]<y[0]):
        return -1
    elif(x[0]==y[0]):
        if(x[1]<y[1]):
            return -1
        else:
            return 1
    else:
        return 1
def find(x):
    if(p[x]!=x):
        p[x]=find(p[x])
    return p[x]
def union(x,y):
    m=find(x)
    n=find(y)
    if(m!=n):
        s[0]-=1
        if(r[m]>r[n]):
            p[n]=m
        elif(r[n]>r[m]):
            p[m]=n
        else:
            p[n]=m
            r[m]+=1
"""*********************************************************************************"""
n=input()
l=map(int,raw_input().split())
r=map(int,raw_input().split())
k=[]
ine=[]
for i in range(n):
    ine.append([l[i],r[i],i])
t=0
while(len(ine)!=0):
    p=[]
    for i in range(len(ine)):
        if(ine[i][0]==0 and ine[i][1]==0):
            p.append(ine[i][2])
    r=len(p)
    if(r==0):
        t=1
        break
    f=[]
    j=0
    d=0
    for i in range(len(ine)):
        if(j<len(p) and p[j]==ine[i][2]):
            r-=1
            d+=1
            j+=1
        else:
            f.append([ine[i][0]-d,ine[i][1]-r,ine[i][2]])
    k.append(p[::])
    ine=f[::]
if(t==1):
    print"NO"
    exit()
r=len(k)
f=[0]*n
for i in range(len(k)):
    for j in range(len(k[i])):
        f[k[i][j]]=str(r)
    r-=1
print "YES"
print " ".join(f)


from __future__ import print_function # for PyPy2
from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math

g   = lambda : stdin.readline().strip()
gl  = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")

n, = gil()
l, r = gil(), gil()
ans = [0]*(n)
cnum, stack = n, []
while 1:

	for i in xrange(n):
		if l[i] == r[i] == 0:
			ans[i] = cnum
			stack.append(i)

	if len(stack) == 0 : break
	cnum -= 1
	while stack:
		i = stack.pop()
		for j in range(i, n):
			l[j] -= 1

		for j in range(i):
			r[j] -= 1

flag = min(ans) > 0
print("YES" if flag else "NO")
if flag:print(*ans)


from __future__ import print_function # for PyPy2
from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math

g   = lambda : stdin.readline().strip()
gl  = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")

n, = gil()
l, r = gil(), gil()
ans = [0]*(n)
cnum, stack = n, []
while 1:

	for i in xrange(n):
		if l[i] == r[i] == 0:
			ans[i] = cnum
			stack.append(i)

	if len(stack) == 0 : break
	cnum -= 1
	while stack:
		i = stack.pop()
		for j in range(i, n):
			l[j] -= 1

		for j in range(i):
			r[j] -= 1

flag = min(ans) > 0
print("YES" if flag else "NO")
if flag:print(ans)


from collections import defaultdict as ddic, deque, Counter
from itertools import combinations, permutations, product
import bisect, heapq
YES, NO = "YES", "NO"

rr = raw_input
rrm = lambda: map(int, rr().split())

def solve(N, L, R):
    IMP = (False, [])
    A = map(list, zip(L, R))
    ans = [-1] * N
    todo = N
    for n in xrange(N, 0, -1):
        if todo == 0: break
        flags = []
        for i, a in enumerate(A):
            if ans[i] == -1 and a[0] == a[1] == 0:
                flags.append(i)
                ans[i] = n
                todo -= 1

        if not flags: return IMP

        flags.append(len(A))
        flagset = set(flags)
        for ix, r in enumerate(flags):
            right = len(flags) - 1 - ix
            left = len(flags) - 1 - right

            if ix:
                l = flags[ix-1] + 1
            else:
                l = 0

            for k in xrange(l, r):
                if k not in flagset and ans[k] == -1:
                    A[k][0] -= left
                    A[k][1] -= right
                    if A[k][0] < 0:
                        return IMP
                    if A[k][1] < 0:
                        return IMP

    return (True, ans)

result, ans = solve(int(rr()), rrm(), rrm())
if result:
    print YES
    print " ".join(map(str, ans))
else:
    print NO


n = int(input())
l = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]

for i in range(n):
    if l[i] > i or r[i] > n - i - 1:
        print('NO')
        break
else:
    items = [(-l[i]-r[i],i) for i in range(n)]
    items.sort()
    vals = [1] * n
    m = 1
    for i in range(1, n):
        if items[i-1][0] != items[i][0]:
            m += 1
        vals[items[i][1]] = m

    print('YES')
    print(' '.join(str(i) for i in vals))


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const int mod=998244353,r=3;//generator//primitive root
int big(int b,int p)
{
  int ret=1;
  while(p)
  {
    if(p%2)ret=(1LL*ret*b)%mod;
    b=(1LL*b*b)%mod;p/=2;
  }
  return ret;
}
void fft(vector<int>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    int wlen=inv?big(r,mod-1-(mod-1)/len):big(r,(mod-1)/len);
    for(int i=0;i<n;i+=len)
    {
      int w=1;
      for(int j=0;j<len/2;j++)
      {
        int u=a[i+j],v=(1LL*a[i+j+len/2]*w)%mod;
        a[i+j]=u+v<mod?u+v:u+v-mod;
        a[i+j+len/2]=u-v>=0?u-v:u-v+mod;
        w=(1LL*w*wlen)%mod;
      }
    }
  }
  if(inv)
  {
    int ni=big(n,mod-2);
    for(auto &x:a)x=(1LL*x*ni)%mod;
  }
}
vector<int>multiply(vector<int>&a,int k)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+a.size();
  int n=1;while(n<sz)n<<=1;
  vector<int>fa(a.begin(),a.end());
  fa.resize(n);fft(fa,false);
  for(int i=0;i<n;i++)fa[i]=big(fa[i],k);
  fft(fa,true);return fa;
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(N+1,0);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  a=multiply(a,k);
  for(int i=1;i<a.size();i++)
    if(a[i])cout<<i<<" ";
  cout<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;

const double pi=acos(-1.0);
struct cmp
{
  double x,y;
  cmp(double a=0,double b=0):x(a),y(b){}
  cmp operator+(cmp c){return cmp(x+c.x,y+c.y);}
  cmp operator-(cmp c){return cmp(x-c.x,y-c.y);}
  cmp operator*(cmp c){return cmp(x*c.x-y*c.y,x*c.y+y*c.x);}
  cmp operator/(double d){return cmp(x/d,y/d);}
  void operator*=(cmp c){double a=x*c.x-y*c.y,b=x*c.y+y*c.x;x=a,y=b;}
  void operator/=(double d){x/=d,y/=d;}
};
void fft(vector<cmp>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    double ang=2*pi/len*(inv?-1:1);
    cmp wlen(cos(ang),sin(ang));
    for(int i=0;i<n;i+=len)
    {
      cmp w(1);
      for(int j=0;j<len/2;j++)
      {
        cmp u=a[i+j],v=a[i+j+len/2]*w;
        a[i+j]=u+v;a[i+j+len/2]=u-v;
        w*=wlen;
      }
    }
  }
  if(inv)for(auto &x:a)x/=n;
}
vector<int>multiply(vector<int>&a,vector<int>&b)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+b.size();
  int n=1;while(n<sz)n<<=1;
  vector<cmp>fa(a.begin(),a.end());
  vector<cmp>fb(b.begin(),b.end());
  fa.resize(n);fb.resize(n);
  fft(fa,false);fft(fb,false);
  for(int i=0;i<n;i++)fa[i]*=fb[i];
  fft(fa,true);vector<int>ret(n);
  for(int i=0;i<n;i++)
    ret[i]=round(fa[i].x);
  return ret;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(1001),ret(1001);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  ret[0]=1;
  while(k)
  {
    if(k%2)ret=multiply(ret,a);
    a=multiply(a,a);k/=2;
  }
  for(int i=0;i<=ret.size();i++)
    if(ret[i])cout<<i<<" ";
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2];
bitset<N+1>dp1,dp2;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;cin>>n>>k;k--;vector<int>v;
	for(int i=1;i<=n;i++)
	{
		cin>>aa[i],dp1[aa[i]]=1;
		v.push_back(aa[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	n=v.size();
	while(k--)
	{
		dp2.reset();
		for(int i=0;i<n;i++)
			dp2|=(dp1<<v[i]);
		dp1=dp2;
	}
	for(int i=1;i<=N;i++)
		if(dp1[i])cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const double pi=acos(-1.0);
void fft(vector<complex<double> >&a,bool inv)
{
	int n=a.size();
	for(int i=1,j=0;i<n;i++)
	{
		int bit=n/2;
		for( ;j&bit;bit/=2)
			j^=bit;
		j^=bit;
		if(i<j)swap(a[i],a[j]);
	}
	for(int ln=2;ln<=n;ln*=2)
	{
		double ang=2*pi/ln*(inv?-1:1);
		complex<double>wlen(cos(ang),sin(ang));
		for(int i=0;i<n;i+=ln)
		{
			complex<double>w(1);
			for(int j=0;j<ln/2;j++)
			{
				complex<double>u=a[i+j],v=a[i+j+ln/2]*w;
				a[i+j]=u+v;a[i+j+ln/2]=u-v;
				w*=wlen;
			}
		}
	}
	if(inv)for(auto &x:a)x/=n;
}
vector<int>multiply(vector<int>&a,vector<int>&b)
{
	int sz=a.size()+b.size();
	int n=1;while(n<sz)n*=2;
	vector<complex<double> >fa(a.begin(),a.end());
	vector<complex<double> >fb(b.begin(),b.end());
	fa.resize(n);fb.resize(n);
	fft(fa,false);fft(fb,false);
	for(int i=0;i<n;i++)fa[i]*=fb[i];
	fft(fa,true);vector<int>ret(n);
	for(int i=0;i<n;i++)
		ret[i]=round(fa[i].real());
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;cin>>n>>k;vector<int>a(1001,0);
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;a[x]=1;
	}
	vector<int>ans(1001,0);ans[0]=1;
	while(k)
	{
		if(k%2)ans=multiply(ans,a);
		a=multiply(a,a);k/=2;
	}
	for(int i=1;i<ans.size();i++)
		if(ans[i])cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;

const double pi=acos(-1.0);
struct cmp
{
  double x,y;
  cmp(double a=0,double b=0):x(a),y(b){}
  cmp operator+(cmp c){return cmp(x+c.x,y+c.y);}
  cmp operator-(cmp c){return cmp(x-c.x,y-c.y);}
  cmp operator*(cmp c){return cmp(x*c.x-y*c.y,x*c.y+y*c.x);}
  cmp operator/(double d){return cmp(x/d,y/d);}
  void operator*=(cmp c){double a=x*c.x-y*c.y,b=x*c.y+y*c.x;x=a,y=b;}
  void operator/=(double d){x/=d,y/=d;}
};
void fft(vector<cmp>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    double ang=2*pi/len*(inv?-1:1);
    cmp wlen(cos(ang),sin(ang));
    for(int i=0;i<n;i+=len)
    {
      cmp w(1);
      for(int j=0;j<len/2;j++)
      {
        cmp u=a[i+j],v=a[i+j+len/2]*w;
        a[i+j]=u+v;a[i+j+len/2]=u-v;
        w*=wlen;
      }
    }
  }
  if(inv)for(auto &x:a)x/=n;
}
vector<int>multiply(vector<int>&a,vector<int>&b)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+b.size();
  int n=1;while(n<sz)n<<=1;
  vector<cmp>fa(a.begin(),a.end());
  vector<cmp>fb(b.begin(),b.end());
  fa.resize(n);fb.resize(n);
  fft(fa,false);fft(fb,false);
  for(int i=0;i<n;i++)fa[i]*=fb[i];
  fft(fa,true);vector<int>ret(n);
  for(int i=0;i<n;i++)
    ret[i]=round(fa[i].x);
  return ret;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(1001),ret(1001);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  ret[0]=1;
  while(k)
  {
    if(k%2)ret=multiply(ret,a);
    a=multiply(a,a);k/=2;
  }
  for(int i=0;i<ret.size();i++)
    if(ret[i])cout<<i<<" ";
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int aa[N+2];
bitset<N+1>dp1,dp2;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;cin>>n>>k;k--;
	for(int i=1;i<=n;i++)
		cin>>aa[i],dp1[aa[i]]=1;
	while(k--)
	{
		dp2.reset();
		for(int i=1;i<=n;i++)
			dp2|=(dp1<<aa[i]);
		dp1=dp2;
	}
	for(int i=1;i<=N;i++)
		if(dp1[i])cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const int mod1=1004535809,mod2=998244353,r=3;//generator//primitive root
int big(int b,int p,int mod)
{
  int ret=1;
  while(p)
  {
    if(p%2)ret=(1LL*ret*b)%mod;
    b=(1LL*b*b)%mod;p/=2;
  }
  return ret;
}
void fft(vector<int>&a,bool inv,int mod)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    int wlen=inv?big(r,mod-1-(mod-1)/len,mod):big(r,(mod-1)/len,mod);
    for(int i=0;i<n;i+=len)
    {
      int w=1;
      for(int j=0;j<len/2;j++)
      {
        int u=a[i+j],v=(1LL*a[i+j+len/2]*w)%mod;
        a[i+j]=u+v<mod?u+v:u+v-mod;
        a[i+j+len/2]=u-v>=0?u-v:u-v+mod;
        w=(1LL*w*wlen)%mod;
      }
    }
  }
  if(inv)
  {
    int ni=big(n,mod-2,mod);
    for(auto &x:a)x=(1LL*x*ni)%mod;
  }
}
vector<int>multiply(vector<int>&a,int k,int mod)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size();
  int n=1;while(n<sz)n<<=1;
  vector<int>fa(a.begin(),a.end());
  fa.resize(n);fft(fa,false,mod);
  for(int i=0;i<n;i++)fa[i]=big(fa[i],k,mod);
  fft(fa,true,mod);return fa;
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(N+1,0),b;
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  b=a;
  a=multiply(a,k,mod1);
  b=multiply(b,k,mod2);
  for(int i=1;i<a.size();i++)
    if(a[i]||b[i])cout<<i<<" ";
  cout<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;

const double pi=acos(-1.0);
struct cmp
{
  double x,y;
  cmp(double a=0,double b=0):x(a),y(b){}
  cmp operator+(cmp c){return cmp(x+c.x,y+c.y);}
  cmp operator-(cmp c){return cmp(x-c.x,y-c.y);}
  cmp operator*(cmp c){return cmp(x*c.x-y*c.y,x*c.y+y*c.x);}
  cmp operator/(double d){return cmp(x/d,y/d);}
  void operator*=(cmp c){double a=x*c.x-y*c.y,b=x*c.y+y*c.x;x=a,y=b;}
  void operator/=(double d){x/=d,y/=d;}
};
void fft(vector<cmp>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    double ang=2*pi/len*(inv?-1:1);
    cmp wlen(cos(ang),sin(ang));
    for(int i=0;i<n;i+=len)
    {
      cmp w(1);
      for(int j=0;j<len/2;j++)
      {
        cmp u=a[i+j],v=a[i+j+len/2]*w;
        a[i+j]=u+v;a[i+j+len/2]=u-v;
        w*=wlen;
      }
    }
  }
  if(inv)for(auto &x:a)x/=n;
}
vector<int>multiply(vector<int>&a,vector<int>&b)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+b.size();
  int n=1;while(n<sz)n<<=1;
  vector<cmp>fa(a.begin(),a.end());
  vector<cmp>fb(b.begin(),b.end());
  fa.resize(n);fb.resize(n);
  fft(fa,false);fft(fb,false);
  for(int i=0;i<n;i++)fa[i]*=fb[i];
  fft(fa,true);vector<int>ret(n);
  for(int i=0;i<n;i++)
    ret[i]=round(fa[i].x);
  return ret;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(1001),ret(1001);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  ret[0]=1;
  while(k)
  {
    if(k%2)ret=multiply(ret,a);
    a=multiply(a,a);k/=2;
  }
  for(int i=1;i<ret.size();i++)
    if(ret[i])cout<<i<<" ";
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const double pi=acos(-1.0);
void fft(vector<complex<double> >&a,bool inv)
{
	int n=a.size();
	for(int i=1,j=0;i<n;i++)
	{
		int bit=n/2;
		for( ;j&bit;bit/=2)
			j^=bit;
		j^=bit;
		if(i<j)swap(a[i],a[j]);
	}
	for(int ln=2;ln<=n;ln*=2)
	{
		double ang=2*pi/ln*(inv?-1:1);
		complex<double>wlen(cos(ang),sin(ang));
		for(int i=0;i<n;i+=ln)
		{
			complex<double>w(1);
			for(int j=0;j<ln/2;j++)
			{
				complex<double>u=a[i+j],v=a[i+j+ln/2]*w;
				a[i+j]=u+v;a[i+j+ln/2]=u-v;
				w*=wlen;
			}
		}
	}
	if(inv)for(auto &x:a)x/=n;
}
vector<int>multiply(vector<int>&a,vector<int>&b)
{
	int sz=a.size()+b.size();
	int n=1;while(n<sz)n*=2;
	vector<complex<double> >fa(a.begin(),a.end());
	vector<complex<double> >fb(b.begin(),b.end());
	fa.resize(n);fb.resize(n);
	fft(fa,false);fft(fb,false);
	for(int i=0;i<n;i++)fa[i]*=fb[i];
	fft(fa,true);vector<int>ret(n);
	for(int i=0;i<n;i++)
	{
		ret[i]=round(fa[i].real());
		if(ret[i]>1)ret[i]=1;
	}
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;cin>>n>>k;vector<int>a(1001,0);
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;a[x]=1;
	}
	vector<int>ans(1001,0);ans[0]=1;
	while(k)
	{
		if(k%2)ans=multiply(ans,a);
		a=multiply(a,a);k/=2;
	}
	for(int i=1;i<ans.size();i++)
		if(ans[i])cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const int mod=1004535809,r=3;//generator//primitive root
int big(int b,int p)
{
  int ret=1;
  while(p)
  {
    if(p%2)ret=(1LL*ret*b)%mod;
    b=(1LL*b*b)%mod;p/=2;
  }
  return ret;
}
void fft(vector<int>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    int wlen=inv?big(r,mod-1-(mod-1)/len):big(r,(mod-1)/len);
    for(int i=0;i<n;i+=len)
    {
      int w=1;
      for(int j=0;j<len/2;j++)
      {
        int u=a[i+j],v=(1LL*a[i+j+len/2]*w)%mod;
        a[i+j]=u+v<mod?u+v:u+v-mod;
        a[i+j+len/2]=u-v>=0?u-v:u-v+mod;
        w=(1LL*w*wlen)%mod;
      }
    }
  }
  if(inv)
  {
    int ni=big(n,mod-2);
    for(auto &x:a)x=(1LL*x*ni)%mod;
  }
}
vector<int>multiply(vector<int>&a,int k)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+a.size();
  int n=1;while(n<sz)n<<=1;
  vector<int>fa(a.begin(),a.end());
  fa.resize(n);fft(fa,false);
  for(int i=0;i<n;i++)fa[i]=big(fa[i],k);
  fft(fa,true);return fa;
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(N+1,0);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  a=multiply(a,k);
  for(int i=1;i<a.size();i++)
    if(a[i])cout<<i<<" ";
  cout<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const int mod=786433,r=10;//generator//primitive root
int big(int b,int p)
{
  int ret=1;
  while(p)
  {
    if(p%2)ret=(1LL*ret*b)%mod;
    b=(1LL*b*b)%mod;p/=2;
  }
  return ret;
}
void fft(vector<int>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    int wlen=inv?big(r,mod-1-(mod-1)/len):big(r,(mod-1)/len);
    for(int i=0;i<n;i+=len)
    {
      int w=1;
      for(int j=0;j<len/2;j++)
      {
        int u=a[i+j],v=(1LL*a[i+j+len/2]*w)%mod;
        a[i+j]=u+v<mod?u+v:u+v-mod;
        a[i+j+len/2]=u-v>=0?u-v:u-v+mod;
        w=(1LL*w*wlen)%mod;
      }
    }
  }
  if(inv)
  {
    int ni=big(n,mod-2);
    for(auto &x:a)x=(1LL*x*ni)%mod;
  }
}
vector<int>multiply(vector<int>&a,int k)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+a.size();
  int n=1;while(n<sz)n<<=1;
  vector<int>fa(a.begin(),a.end());
  fa.resize(n);fft(fa,false);
  for(int i=0;i<n;i++)fa[i]=big(fa[i],k);
  fft(fa,true);return fa;
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(1001,0);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  a=multiply(a,k);
  for(int i=1;i<a.size();i++)
    if(a[i])cout<<i<<" ";
  cout<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const int mod1=1004535809,mod2=998244353,r=3;//generator//primitive root
int big(int b,int p,int mod)
{
  int ret=1;
  while(p)
  {
    if(p%2)ret=(1LL*ret*b)%mod;
    b=(1LL*b*b)%mod;p/=2;
  }
  return ret;
}
void fft(vector<int>&a,bool inv,int mod)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    int wlen=inv?big(r,mod-1-(mod-1)/len,mod):big(r,(mod-1)/len,mod);
    for(int i=0;i<n;i+=len)
    {
      int w=1;
      for(int j=0;j<len/2;j++)
      {
        int u=a[i+j],v=(1LL*a[i+j+len/2]*w)%mod;
        a[i+j]=u+v<mod?u+v:u+v-mod;
        a[i+j+len/2]=u-v>=0?u-v:u-v+mod;
        w=(1LL*w*wlen)%mod;
      }
    }
  }
  if(inv)
  {
    int ni=big(n,mod-2,mod);
    for(auto &x:a)x=(1LL*x*ni)%mod;
  }
}
vector<int>multiply(vector<int>&a,int k,int mod)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+a.size();
  int n=1;while(n<sz)n<<=1;
  vector<int>fa(a.begin(),a.end());
  fa.resize(n);fft(fa,false,mod);
  for(int i=0;i<n;i++)fa[i]=big(fa[i],k,mod);
  fft(fa,true,mod);return fa;
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(N+1,0),b;
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  b=a;
  a=multiply(a,k,mod1);
  b=multiply(b,k,mod2);
  for(int i=1;i<a.size();i++)
    if(a[i])cout<<i<<" ";
  cout<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;

const double pi=acos(-1.0);
struct cmp
{
  double x,y;
  cmp(double a=0,double b=0):x(a),y(b){}
  cmp operator+(cmp c){return cmp(x+c.x,y+c.y);}
  cmp operator-(cmp c){return cmp(x-c.x,y-c.y);}
  cmp operator*(cmp c){return cmp(x*c.x-y*c.y,x*c.y+y*c.x);}
  cmp operator/(double d){return cmp(x/d,y/d);}
  void operator*=(cmp c){double a=x*c.x-y*c.y,b=x*c.y+y*c.x;x=a,y=b;}
  void operator/=(double d){x/=d,y/=d;}
};
void fft(vector<cmp>&a,bool inv)
{
  int n=a.size();
  for(int i=1,j=0;i<n;i++)
  {
    int bit=n>>1;
    for( ;bit&j;bit>>=1)
      j^=bit;
    j^=bit;
    if(i<j)swap(a[i],a[j]);
  }
  for(int len=2;len<=n;len<<=1)
  {
    double ang=2*pi/len*(inv?-1:1);
    cmp wlen(cos(ang),sin(ang));
    for(int i=0;i<n;i+=len)
    {
      cmp w(1);
      for(int j=0;j<len/2;j++)
      {
        cmp u=a[i+j],v=a[i+j+len/2]*w;
        a[i+j]=u+v;a[i+j+len/2]=u-v;
        w*=wlen;
      }
    }
  }
  if(inv)for(auto &x:a)x/=n;
}
vector<int>multiply(vector<int>&a,vector<int>&b)
{
  //a^0+a^1+a^2+a^3+... format
  int sz=a.size()+b.size();
  int n=1;while(n<sz)n<<=1;
  vector<cmp>fa(a.begin(),a.end());
  vector<cmp>fb(b.begin(),b.end());
  fa.resize(n);fb.resize(n);
  fft(fa,false);fft(fb,false);
  for(int i=0;i<n;i++)fa[i]*=fb[i];
  fft(fa,true);vector<int>ret(n);
  for(int i=0;i<n;i++)
    ret[i]=(bool)((int)round(fa[i].x));
  return ret;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;vector<int>a(1001),ret(1001);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;a[x]=1;
  }
  ret[0]=1;
  while(k)
  {
    if(k%2)ret=multiply(ret,a);
    a=multiply(a,a);k/=2;
  }
  for(int i=1;i<ret.size();i++)
    if(ret[i])cout<<i<<" ";
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> fastpow(vector<bool> vec, int power)
{
    if(power == 1)
        return vec;
    vector<bool> res = fastpow(vec, power / 2);
    vector<bool> ret;
    multiply(res, res, ret);
    if(power & 1)
    {
        vector<bool> ret2;
        multiply(ret, vec, ret2);
        return ret2;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> fastpow(vector<bool>& vec, int power)
{
    if(power == 1)
        return vec;
    vector<bool> res = fastpow(vec, power / 2);
    vector<bool> ret;
    multiply(res, res, ret);
    if(power & 1)
    {
        vector<bool> ret2;
        multiply(ret, vec, ret2);
        return ret2;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> fastpow(vector<bool> vec, int power)
{
    if(power == 1)
        return vec;
    if(power & 1)
    {
        vector<bool> res1 = fastpow(vec, power - 1);
        vector<bool> res2(vec.size() + res1.size());
        multiply(vec, res1, res2);
        return res2;
    }
    vector<bool> res = fastpow(vec, power / 2);
    vector<bool> ret(res.size() * 2);
    multiply(res, res, ret);
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> ret;

vector<bool> fastpow(vector<bool> vec, int power)
{
    if(power == 1)
        return vec;
    if(power & 1)
    {
        multiply(fastpow(vec, power - 1), vec, ret);
        return ret;
    }
    ret= fastpow(vec, power / 2);
    multiply(ret, ret, ret);
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> ret;

vector<bool> fastpow(vector<bool>& vec, int power)
{
    if(power == 1)
        return vec;
    ret = fastpow(vec, power / 2);
    multiply(ret, ret, ret);
    if(power & 1)
        multiply(ret, vec, ret);
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> ret;

vector<bool> fastpow(vector<bool> vec, int power)
{
    if(power == 1)
        return vec;
    ret = fastpow(vec, power / 2);
    multiply(ret, ret, ret);
    if(power & 1)
        multiply(ret, vec, ret);
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define MOD 998244353
#define EPS 1e-6
#define PI 3.14159265

typedef complex<double> base;
void fft(vector<base> & a, bool invert) {
	int n = (int)a.size();

	for(int i = 1, j = 0; i<n; ++i) {
		int bit = n >> 1;
		for(; j >= bit; bit >>= 1)
			j -= bit;
		j += bit;
		if(i < j)
			swap(a[i], a[j]);
	}

	for(int len = 2; len <= n; len <<= 1) {
		double ang = 2 * PI / len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for(int i = 0; i<n; i += len) {
			base w(1);
			for(int j = 0; j<len / 2; ++j) {
				base u = a[i + j], v = a[i + j + len / 2] * w;
				a[i + j] = u + v;
				a[i + j + len / 2] = u - v;
				w *= wlen;
			}
		}
	}
	if(invert)
	for(int i = 0; i<n; ++i)
		a[i] /= n;
}

void multiply(const vector<bool> & a, const vector<bool> & b, vector<bool> & res) {
	vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	size_t n = 1;
	while(n < max(a.size(), b.size()))  n <<= 1;
	n <<= 1;
	n = min(int(n), 1 << 20);
	fa.resize(n), fb.resize(n);

	fft(fa, false), fft(fb, false);
	for(size_t i = 0; i<n; ++i)
		fa[i] *= fb[i];
	fft(fa, true);

	res.resize(n);
	for(size_t i = 0; i<n; ++i)
		res[i] = int(fa[i].real() + 0.5);
}

vector<bool> fastpow(vector<bool> vec, int power)
{
    if(power == 1)
        return vec;
    vector<bool> res = fastpow(vec, power / 2);
    vector<bool> ret(res.size() * 2 + 1);
    multiply(res, res, ret);
    if(power & 1)
    {
        vector<bool> ret2(ret.size() + res.size() + 1);
        multiply(ret, vec, ret2);
        return ret2;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    vector<bool> vec(1001);
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        vec[a] = 1;
    }
    vector<bool> ret = fastpow(vec, k);
    for(int i = 0; i < ret.size(); i++)
    {
        if(ret[i])
            cout << i << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<int> a, b, c;

void fft(vector<complex<double>> &a, bool invert) {
    int n = a.size();
    for (int i = 1, j = 0; i < n; i++) {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1) {
            j ^= bit;
        }
        j ^= bit;
        if (i < j) {
            swap(a[i], a[j]);
        }
    }
    for (int len = 2; len <= n; len <<= 1) {
        double ang = 2 * acos(-1.0) / len * (invert ? -1 : 1);
        complex<double> wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) {
            complex<double> w(1);
            for (int j = 0; j < len / 2; j++) {
                complex<double> u = a[i+j], v = a[i + j + len / 2] * w;
                a[i + j] = u + v;
                a[i + j +len / 2] = u - v;
                w *= wlen;
            }
        }
    }
    if (invert) {
        for (complex<double> &x : a) {
            x /= n;
        }
    }
}

vector<int> multiply(const vector<int> &a, const vector<int> &b) {
    /** x^0 + x^1 + x^2 + x^3 ... format **/
    vector<complex<double>> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) {
        n <<= 1;
    }
    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++) {
        fa[i] *= fb[i];
    }
    fft(fa, true);
    vector<int> result(n);
    for (int i = 0; i < n; i++) {
        result[i] = round(fa[i].real());
    }
    return result;
}

vector<int> power(vector<int> a, int b){
    if (b == 1) {
        return a;
    }
    vector<int> res;
    res.push_back(1);
    while (b > 0) {
        if (b & 1) {
            res = multiply(a, res);
        }
        a = multiply(a, a);
        b >>= 1;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int mx = *max_element(a.begin(), a.end());
    for (int i = 0; i <= mx; i++) {
        b.push_back(0);
    }
    for (auto i : a) {
        b[i] = 1;
    }
    c = power(b, k);
//    for (int i = 0; i < c.size(); i++) {
//        cout << i << " : " << c[i] << endl;
//    }
    for (int i = 0; i < c.size(); i++) {
        if (c[i] > 0) {
            cout << i << " ";
        }
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

namespace ntt {
  int base = 1;
  vector<int> roots = {0, 1};
  vector<int> rev = {0, 1};
  int max_base = -1;
  int root = -1;

  void init() {
    int tmp = md - 1;
    max_base = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      max_base++;
    }
    root = 2;
    while (true) {
      if (power(root, 1 << max_base) == 1) {
        if (power(root, 1 << (max_base - 1)) != 1) {
          break;
        }
      }
      root++;
    }
  }

  void ensure_base(int nbase) {
    if (max_base == -1) {
      init();
    }
    if (nbase <= base) {
      return;
    }
    assert(nbase <= max_base);
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      int z = power(root, 1 << (max_base - 1 - base));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
        roots[(i << 1) + 1] = mul(roots[i], z);
      }
      base++;
    }
  }

  void fft(vector<int> &a) {
    int n = (int) a.size();
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          int x = a[i + j];
          int y = mul(a[i + j + k], roots[j + k]);
          a[i + j] = x + y - md;
          if (a[i + j] < 0) a[i + j] += md;
          a[i + j + k] = x - y + md;
          if (a[i + j + k] >= md) a[i + j + k] -= md;
        }
      }
    }
  }

  vector<int> multiply(vector<int> a, vector<int> b, int eq = 0) {
    int need = (int) (a.size() + b.size() - 1);
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    a.resize(sz);
    b.resize(sz);
    fft(a);
    if (eq) b = a; else fft(b);
    int inv_sz = inv(sz);
    for (int i = 0; i < sz; i++) {
      a[i] = mul(mul(a[i], b[i]), inv_sz);
    }
    reverse(a.begin() + 1, a.end());
    fft(a);
    a.resize(need);
    return a;
  }

  vector<int> square(vector<int> a) {
    return multiply(a, a, 1);
  }
}

vector<int> bigMod(vector<int> a, int b){
    if (b == 1) {
        return a;
    }
    vector<int> res;
    res.push_back(1);
    while (b > 0) {
        if (b & 1) {
            res = ntt::multiply(a, res);
        }
        a = ntt::multiply(a, a);
        b >>= 1;
    }
    return res;
}

vector<int> a, b, c;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int mx = *max_element(a.begin(), a.end());
    for (int i = 0; i <= mx; i++) {
        b.push_back(0);
    }
    for (auto i : a) {
        b[i] = 1;
    }
    c = bigMod(b, k);
    for (int i = 0; i < c.size(); i++) {
        if (c[i] > 0) {
            cout << i << " ";
        }
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

namespace ntt {
  int base = 1;
  vector<int> roots = {0, 1};
  vector<int> rev = {0, 1};
  int max_base = -1;
  int root = -1;

  void init() {
    int tmp = md - 1;
    max_base = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      max_base++;
    }
    root = 2;
    while (true) {
      if (power(root, 1 << max_base) == 1) {
        if (power(root, 1 << (max_base - 1)) != 1) {
          break;
        }
      }
      root++;
    }
  }

  void ensure_base(int nbase) {
    if (max_base == -1) {
      init();
    }
    if (nbase <= base) {
      return;
    }
    assert(nbase <= max_base);
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      int z = power(root, 1 << (max_base - 1 - base));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
        roots[(i << 1) + 1] = mul(roots[i], z);
      }
      base++;
    }
  }

  void fft(vector<int> &a) {
    int n = (int) a.size();
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          int x = a[i + j];
          int y = mul(a[i + j + k], roots[j + k]);
          a[i + j] = x + y - md;
          if (a[i + j] < 0) a[i + j] += md;
          a[i + j + k] = x - y + md;
          if (a[i + j + k] >= md) a[i + j + k] -= md;
        }
      }
    }
  }

  vector<int> multiply(vector<int> a, vector<int> b, int eq = 0) {
    int need = (int) (a.size() + b.size() - 1);
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    a.resize(sz);
    b.resize(sz);
    fft(a);
    if (eq) b = a; else fft(b);
    int inv_sz = inv(sz);
    for (int i = 0; i < sz; i++) {
      a[i] = mul(mul(a[i], b[i]), inv_sz);
    }
    reverse(a.begin() + 1, a.end());
    fft(a);
    a.resize(need);
    return a;
  }

  vector<int> square(vector<int> a) {
    return multiply(a, a, 1);
  }
}

vector<int> a, b, c;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int mx = *max_element(a.begin(), a.end());
    for (int i = 0; i <= mx; i++) {
        b.push_back(0);
    }
    for (auto i : a) {
        b[i] = 1;
    }
    if (k == 1) {
        sort(a.begin(), a.end());
        for (auto i : a) {
            cout << i << " ";
        }
        puts("");
        return 0;
    }
//    for (int i = 0; i < b.size(); i++) {
//        cout << i << " " << b[i] << endl;
//    }
    c = ntt::multiply(b, b);
    for (int i = 2; i < k; i++) {
        c = ntt::multiply(c, b);
    }
    for (int i = 1; i < c.size(); i++) {
        if (c[i] > 0) {
            cout << i << " ";
        }
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<int> a, b, c;

void fft(vector<complex<double>> &a, bool invert) {
    int n = a.size();
    for (int i = 1, j = 0; i < n; i++) {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1) {
            j ^= bit;
        }
        j ^= bit;
        if (i < j) {
            swap(a[i], a[j]);
        }
    }
    for (int len = 2; len <= n; len <<= 1) {
        double ang = 2 * acos(-1.0) / len * (invert ? -1 : 1);
        complex<double> wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) {
            complex<double> w(1);
            for (int j = 0; j < len / 2; j++) {
                complex<double> u = a[i+j], v = a[i + j + len / 2] * w;
                a[i + j] = u + v;
                a[i + j +len / 2] = u - v;
                w *= wlen;
            }
        }
    }
    if (invert) {
        for (complex<double> &x : a) {
            x /= n;
        }
    }
}

vector<int> multiply(const vector<int> &a, const vector<int> &b) {
    /** x^0 + x^1 + x^2 + x^3 ... format **/
    vector<complex<double>> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) {
        n <<= 1;
    }
    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++) {
        fa[i] *= fb[i];
    }
    fft(fa, true);
    vector<int> result(n);
    for (int i = 0; i < n; i++) {
        result[i] = (round(fa[i].real()) > 0);
    }
    return result;
}

vector<int> power(vector<int> a, int b){
    if (b == 1) {
        return a;
    }
    vector<int> res;
    res.push_back(1);
    while (b > 0) {
        if (b & 1) {
            res = multiply(a, res);
        }
        a = multiply(a, a);
        b >>= 1;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int mx = *max_element(a.begin(), a.end());
    for (int i = 0; i <= mx; i++) {
        b.push_back(0);
    }
    for (auto i : a) {
        b[i] = 1;
    }
    c = power(b, k);
//    for (int i = 0; i < c.size(); i++) {
//        cout << i << " : " << c[i] << endl;
//    }
    for (int i = 0; i < c.size(); i++) {
        if (c[i] > 0) {
            cout << i << " ";
        }
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

namespace ntt {

    void fft(vector<complex<double>> & a, bool invert) {
        int n = a.size();
        for (int i = 1, j = 0; i < n; i++) {
            int bit = n >> 1;
            for (; j & bit; bit >>= 1) {
                j ^= bit;
            }
            j ^= bit;
            if (i < j) {
                swap(a[i], a[j]);
            }
        }
        for (int len = 2; len <= n; len <<= 1) {
            double ang = 2 * acos(-1) / len * (invert ? -1 : 1);
            complex<double> wlen(cos(ang), sin(ang));
            for (int i = 0; i < n; i += len) {
                complex<double> w(1);
                for (int j = 0; j < len / 2; j++) {
                    complex<double> u = a[i + j], v = a[i + j + len / 2] * w;
                    a[i + j] = u + v;
                    a[i + j + len / 2] = u - v;
                    w *= wlen;
                }
            }
        }
        if (invert) {
            for (complex<double> & x : a) {
                x /= n;
            }
        }
    }

    vector<int> multiply(vector<int> const& a, vector<int> const& b) {
        vector<complex<double>> fa(a.begin(), a.end()), fb(b.begin(), b.end());
        int n = 1;
        while (n < a.size() + b.size()) {
            n <<= 1;
        }
        fa.resize(n);
        fb.resize(n);
        fft(fa, false);
        fft(fb, false);
        for (int i = 0; i < n; i++) {
            fa[i] *= fb[i];
        }
        fft(fa, true);
        vector<int> result(n);
        for (int i = 0; i < n; i++) {
            result[i] = (round(fa[i].real()) > 0);
        }
        return result;
    }

    vector<int> bigMod(vector<int> a, int b){
        if (b == 1) {
            return a;
        }
        vector<int> res;
        res.push_back(1);
        while (b > 0) {
            if (b & 1) {
                res = multiply(a, res);
            }
            a = multiply(a, a);
            b >>= 1;
        }
        return res;
    }
}

vector<int> a, b, c;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int mx = *max_element(a.begin(), a.end());
    for (int i = 0; i <= mx; i++) {
        b.push_back(0);
    }
    for (auto i : a) {
        b[i] = 1;
    }
    c = ntt::bigMod(b, k);
    for (int i = 0; i < c.size(); i++) {
        if (c[i] > 0) {
            cout << i << " ";
        }
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

namespace ntt {
    void fft(vector<complex<double>> & a, bool invert) {
        int n = a.size();
        for (int i = 1, j = 0; i < n; i++) {
            int bit = n >> 1;
            for (; j & bit; bit >>= 1) {
                j ^= bit;
            }
            j ^= bit;
            if (i < j) {
                swap(a[i], a[j]);
            }
        }
        for (int len = 2; len <= n; len <<= 1) {
            double ang = 2 * acos(-1) / len * (invert ? -1 : 1);
            complex<double> wlen(cos(ang), sin(ang));
            for (int i = 0; i < n; i += len) {
                complex<double> w(1);
                for (int j = 0; j < len / 2; j++) {
                    complex<double> u = a[i + j], v = a[i + j + len / 2] * w;
                    a[i + j] = u + v;
                    a[i + j + len / 2] = u - v;
                    w *= wlen;
                }
            }
        }
        if (invert) {
            for (complex<double> & x : a) {
                x /= n;
            }
        }
    }

    vector<int> multiply(vector<int> const& a, vector<int> const& b) {
        // a^0 + a^1 + a^2 + a^3 ... format
        vector<complex<double>> fa(a.begin(), a.end()), fb(b.begin(), b.end());
        int n = 1;
        while (n < a.size() + b.size()) {
            n <<= 1;
        }
        fa.resize(n);
        fb.resize(n);
        fft(fa, false);
        fft(fb, false);
        for (int i = 0; i < n; i++) {
            fa[i] *= fb[i];
        }
        fft(fa, true);
        vector<int> result(n);
        for (int i = 0; i < n; i++) {
            result[i] = (round(fa[i].real()) > 0);
        }
        return result;
    }

    vector<int> power(vector<int> a, int b){
        if (b == 1) {
            return a;
        }
        vector<int> res;
        res.push_back(1);
        while (b > 0) {
            if (b & 1) {
                res = multiply(a, res);
            }
            a = multiply(a, a);
            b >>= 1;
        }
        return res;
    }
}

vector<int> a, b, c;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int mx = *max_element(a.begin(), a.end());
    for (int i = 0; i <= mx; i++) {
        b.push_back(0);
    }
    for (auto i : a) {
        b[i] = 1;
    }
    c = ntt::power(b, k);
//    for (int i = 0; i < c.size(); i++) {
//        cout << i << " : " << c[i] << endl;
//    }
    for (int i = 0; i < c.size(); i++) {
        if (c[i] > 0) {
            cout << i << " ";
        }
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e6 + 2;
const int M = 1e3 + 3;
int visit[N], a[M];
int ans[N];
int n, k, sz;
void bfs() {
	memset(visit, -1, sizeof visit);
	int level = 0;
	visit[0] = 0;
	while (level <= k + 1) {
		int visit1[N];
		memset(visit1, -1, sizeof visit1);
		for (int i = 0; i < N; ++i) {
			if (visit[i] < level)
				continue;
			if (level == k) {
				ans[sz++] = i;
				continue;
			}
			for (int j = 0; j < n; ++j) {
				if (i + a[j] < N)
					visit1[i + a[j]] = level + 1;

			}
		}
		for (int i = 0; i < N; ++i) {
			visit[i] = visit1[i];
		}
		level++;
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	bfs();
	sort(ans, ans + sz);
	for (int i = 0; i < sz; ++i) {
		printf("%d ", ans[i]);
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e6 + 1;
const int M = 1e3 + 3;

int visit[N], a[M];
int n, k;
void bfs(int source) {
	queue<int> q;
	q.push(source);
	visit[source] = 1;
	int level = 0;
	while (level < k) {
		int sz = q.size();
		while (sz--) {
			int fr = q.front() - a[0];
			q.pop();
			for (int i = 1; i < n; ++i) {
				int num = fr + a[i];
				if (!visit[num]) {
					q.push(num), visit[num] = 1;
				}
			}
		}
		level++;
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	bfs(a[0] * k);
	for (int i = 0; i < N; ++i) {
		if (visit[i]) {
			printf("%d ", i);
		}
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e6;
const int M = 1e3 + 3;
int visit[N], a[M];
int ans[N];
int n, k, size;
void bfs() {
	queue<int> q;
	q.push(0);
	int level = 0;
	while (q.size()) {
		int sz = q.size();
		while (sz--) {
			int fr = q.front();
			q.pop();
			if (level == k) {
				ans[size++] = fr;
				continue;
			}
			for (int i = 0; i < n; ++i) {
				int num = fr + a[i];
				if (visit[num] != level + 1) {
					visit[num] = level + 1;
					q.push(num);
				}
			}
		}
		level++;
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	bfs();
	sort(ans, ans + size);
	for (int i = 0; i < size; ++i) {
		printf("%d ", ans[i]);
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 2e6;
const int M = 1e3 + 3;
int visit[N], a[M];
set<int> ans;
int n, k;
void bfs() {
	queue<int> q;
	q.push(0);
	int level = 0;
	while (q.size() && level <= k) {
		int sz = q.size();
		while (sz--) {
			int fr = q.front();
			if (level == k) {
				ans.insert(fr);
			}
			q.pop();
			visit[fr] = level;
			for (int i = 0; i < n; ++i) {
				if (visit[fr + a[i]] != level + 1) {
					visit[fr + a[i]] = level + 1;
					q.push(fr + a[i]);
				}
			}
		}
		level++;
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	bfs();
	for (std::set<int>::iterator it = ans.begin(); it != ans.end(); ++it) {
		printf("%d ", *(it));
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e6;
const int M = 1e3 + 3;
int visit[N], a[M];
vector<int> ans;
int n, k;
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	queue<int> q;
	q.push(0);
	int level = 0;
	while (q.size() && level <= k) {
		int sz = q.size();
		while (sz--) {
			int fr = q.front();
			q.pop();
			if (level == k) {
				ans.push_back(fr);
				continue;
			}
			visit[fr] = level;
			for (int i = 0; i < n; ++i) {
				int num = fr + a[i];
				if (!visit[num]) {
					visit[num] = 1;
					q.push(num);
				}
			}
		}
		level++;
		memset(visit, 0, sizeof visit);
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < (int) ans.size(); ++i) {
		printf("%d ", ans[i]);
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 2e6;
const int M = 1e3 + 3;
int visit[N], n, k, a[M];
set<int> ans;
int sz;
void dfs(int source, int nK) {
	if (nK == k) {
		ans.insert(source);
		sz++;
		return;
	}
	visit[source] = 1;
	for (int i = 0; i < n; ++i) {
		if (!visit[source + a[i]]) {
			dfs(source + a[i], nK + 1);
		}
	}
}
int main() {
	scanf("%d%d", &n,&k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	dfs(0, 0);
	for (std::set<int>::iterator it = ans.begin(); it != ans.end(); ++it) {
		printf("%d ", *(it));
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e6 + 2;
const int M = 1e3 + 3;
int visit[N], a[M];
int ans[N];
int n, k, sz;
void bfs() {
	memset(visit, -1, sizeof visit);
	int level = 0;
	visit[0] = 0;
	while (level <= k) {
		for (int i = 0; i < N; ++i) {
			if (visit[i] != level)
				continue;
			if (level == k) {
				ans[sz++] = i;
				continue;
			}
			for (int j = 0; j < n; ++j) {
				if (i + a[j] < N)
					visit[i + a[j]] = level + 1;

			}
		}
		level++;
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	bfs();
	sort(ans, ans + sz);
	for (int i = 0; i < sz; ++i) {
		printf("%d ", ans[i]);
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 1e6;
const int M = 1e3 + 3;

int visit[N], a[M];
int n, k;
void bfs(int source) {
	queue<int> q;
	q.push(source);
	visit[source] = 1;
	int level = 0;
	while (level < k) {
		int sz = q.size();
		while (sz--) {
			int fr = q.front() - a[0];
			q.pop();
			for (int i = 1; i < n; ++i) {
				int num = fr + a[i];
				if (!visit[num]) {
					q.push(num), visit[num] = 1;
				}
			}
		}
		level++;
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	bfs(a[0] * k);
	for (int i = 0; i < N; ++i) {
		if (visit[i]) {
			printf("%d ", i);
		}
	}
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 4e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2 * PI / len * (f ? -1 : 1);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

void Multiplica (vc &a, int k) {
    fft (a, a.size(), 0);

    vc aux = a;
    while (--k) {
        for (int i = 0; i < a.size(); i++)
            a[i] *= aux[i];
    }

    fft(a, a.size(), 1);
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(tam);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] += 1;
    }

    Multiplica(a, k);

    for (int i = 0; i < tam; i++)
        if ((ll)round(a[i].real()) > 0)
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 8e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void Multiplica (vc &a, int k) {
    fft (a, a.size(), 0);

    for (int i = 0; i < a.size(); i++)
        a[i] = pot(a[i], k);

    fft(a, a.size(), 1);
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(tam);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = 1;
    }

    Multiplica(a, k);

    for (int i = 0; i < tam; i++)
        if (a[i].real() > ld(0.5))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 8e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void potencia (vc &a, int k) {
    vc b = a;
    int ln = 10;

    k--;
    while (k) {
        a.resize(a.size()*2);
        b.resize(b.size()*2);

        obtRev(a.size(), ++ln);

        fft(b, b.size(), 0);

        if (k & 1) {
            fft(a, a.size(), 0);
            for (int i = 0; i < a.size(); i++)
                a[i] *= b[i];

            fft(a, a.size(), 1);
            for (int i = 0; i < a.size(); i++)
                if (round(a[i].real()) > 0.5)
                    a[i] = cld(1, 0);
        }

        for (int i = 0; i < b.size(); i++)
            b[i] *= b[i];

        fft(b, b.size(), 1);
        for (int i = 0; i < b.size(); i++)
            if (round(b[i].real()) > 0.5)
                b[i] = cld(1, 0);

        k >>= 1;
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(1024);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = cld(1, 0);
    }

    potencia(a, k);

    for (int i = 0; i <= 1000*k; i++)
        if (round(a[i].real()))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 8e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void potencia (vc &a, int k) {
    vc b = a;
    int ln = 10;

    k--;
    while (k) {
        a.resize(a.size()*2);
        b.resize(b.size()*2);

        obtRev(a.size(), ++ln);

        fft(b, b.size(), 0);

        if (k & 1) {
            fft(a, a.size(), 0);
            for (int i = 0; i < a.size(); i++)
                a[i] *= b[i];

            fft(a, a.size(), 1);
            for (int i = 0; i < a.size(); i++)
                if (round(a[i].real()) > 0.5)
                    a[i] = cld(1, 0);
        }

        for (int i = 0; i < b.size(); i++)
            b[i] *= b[i];

        fft(b, b.size(), 1);
        for (int i = 0; i < b.size(); i++)
            if (round(b[i].real()) > 0.5)
                b[i] = cld(1, 0);

        k >>= 1;
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(1024);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = cld(1, 0);
    }

    potencia(a, k);

    for (int i = 0; i <= 1000*k; i++)
        if (!round(a[i].real()))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 4e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2 * PI / len * (f ? -1 : 1);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void Multiplica (vc &a, int k) {
    fft (a, a.size(), 0);

    for (int i = 0; i < a.size(); i++)
        a[i] = pot(a[i], k);

    fft(a, a.size(), 1);
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(tam);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = 1;
    }

    Multiplica(a, k);

    for (int i = 0; i < tam; i++)
        if (round(a[i].real()) > ld(0))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 8e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void potencia (vc &a, int k) {
    vc b = a;
    int ln = 10;

    k--;
    while (k) {
        a.resize(a.size()*2);
        b.resize(b.size()*2);

        obtRev(a.size(), ++ln);

        fft(b, b.size(), 0);

        if (k & 1) {
            fft(a, a.size(), 0);
            for (int i = 0; i < a.size(); i++)
                a[i] *= b[i];

            fft(a, a.size(), 1);
            for (int i = 0; i < a.size(); i++)
                if (round(a[i].real()))
                    a[i] = cld(1, 0);
        }

        for (int i = 0; i < b.size(); i++)
            b[i] *= b[i];

        fft(b, b.size(), 1);
        for (int i = 0; i < b.size(); i++)
            if (round(b[i].real()))
                b[i] = cld(1, 0);

        k >>= 1;
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(1024);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = cld(1, 0);
    }

    potencia(a, k);

    for (int i = 0; i <= 1000*k; i++)
        if (round(a[i].real()))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 8e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void potencia (vc &a, int k) {
    vc b = a;
    int ln = 10;

    k--;
    while (k) {
        a.resize(a.size()*2);
        b.resize(b.size()*2);

        obtRev(a.size(), ++ln);

        fft(b, b.size(), 0);

        if (k & 1) {
            fft(a, a.size(), 0);
            for (int i = 0; i < a.size(); i++)
                a[i] *= b[i];

            fft(a, a.size(), 1);
            for (int i = 0; i < a.size(); i++)
                if (round(a[i].real()))
                    a[i] = cld(1, 0);
        }

        for (int i = 0; i < b.size(); i++)
            b[i] *= b[i];

        fft(b, b.size(), 1);
        for (int i = 0; i < b.size(); i++)
            if (round(b[i].real()))
                b[i] = cld(1, 0);

        k >>= 1;
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(1024);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = cld(1, 0);
    }

    potencia(a, k);

    for (int i = 0; i <= 1000*k; i++)
        if (!round(a[i].real()))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 8e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] = a[i] / cld(n, 0);
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

void Multiplica (vc &a, vc &b) {
    fft (a, a.size(), 0);

    for (int i = 0; i < a.size(); i++)
        a[i] *= b[i];

    fft(a, a.size(), 1);
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(tam);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = 1;
    }

    vc b(a.begin(), a.end());
    fft (b, tam, 0);

    k--;
    while (k) {
        if (k&1)
            Multiplica(a, b);

        for (int i = 0; i < b.size(); i++)
            b[i] *= b[i];

        k /= 2;
    }

    for (int i = 0; i < tam; i++)
        if (a[i].real() > ld(0.5))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const ld PI = acos(-1.0);

const int M = 4e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2.0L * PI / len * (f ? -1.0L : 1.0L);
        int l2 = len >> 1;

        cld wl(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * wl;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

cld pot (cld b, ll p) {
    cld res = 1;

    while (p) {
        if (p&1)
            res *= b;
        b *= b;
        p >>= 1;
    }

    return res;
}

void potencia (vc &a, int k) {
    vc b(a.begin(), a.end());
    a = vc(b.size());
    a[0] = 1;
    int ln = 10;

    while (k) {
        a.resize(a.size()*2, 0);
        b.resize(b.size()*2, 0);

        obtRev(a.size(), ++ln);

        fft(b, b.size(), 0);

        if (k & 1) {
            fft(a, a.size(), 0);
            for (int i = 0; i < a.size(); i++)
                a[i] *= b[i];

            fft(a, a.size(), 1);
            for (int i = 0; i < a.size(); i++)
                if (ll(a[i].real()+0.5))
                    a[i] = 1;
                else
                    a[i] = 0;
        }

        for (int i = 0; i < b.size(); i++)
            b[i] *= b[i];

        fft(b, b.size(), 1);
        for (int i = 0; i < b.size(); i++)
            if (ll(b[i].real()+.5))
                b[i] = 1;
            else
                b[i] = 0;

        k >>= 1;
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    vc a(1024);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] = 1;
    }

    potencia(a, k);

    for (int i = 0; i < a.size(); i++)
        if (ll(a[i].real()+0.5))
            cout << i << " ";
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

typedef complex<ld> cld;
typedef vector<cld> vc;

const int M = 4e6;
int rev[M];
cld wpw[M];

void fft(vc &a, int n, bool f) {
    for (int i = 0; i < n; i++)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);

    for (int len = 2; len <= n; len <<= 1) {
        ld ang = 2 * M_PI / len * (f ? -1 : 1);
        int l2 = len >> 1;

        cld w(cos(ang), sin(ang));
        wpw[0] = cld(1, 0);
        for (int i = 1; i < l2; i++)
            wpw[i] = wpw[i-1] * w;

        cld t;
        int l, r;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < len / 2; j++) {
                l = i+j, r = i+j+len/2;
                t = a[r] * wpw[j];
                a[r] = a[l] - t;
                a[l] += t;
            }
        }
    }

    if (f)
        for (int i = 0; i < n; i++)
            a[i] /= n;
}

void obtRev (int n, int ln) {
    for (int i = 0; i < n; i++) {
        rev[i] = 0;
        for (int j = 0; j < ln; j++)
            if (i & (1 << j))
                rev[i] |= 1 << (ln - j - 1);
    }
}

void Multiplica (vc &a, int k) {
    fft (a, a.size(), 0);

    vc aux = a;
    while (--k) {
        for (int i = 0; i < a.size(); i++)
            a[i] *= aux[i];
    }

    fft(a, a.size(), 1);
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, k, x;

    cin >> n >> k;

    int tam = 1, lg = 0;
    while (tam < 1000*k)
        tam <<= 1, lg++;
    tam <<= 1, lg++;
    obtRev(tam, lg);

    vc a(tam);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x] += 1;
    }

    Multiplica(a, k);

    for (int i = 0; i < tam; i++)
        if ((ll)round(a[i].real()) > 0)
            cout << i << " ";
    cout << endl;

    return 0;
}