var a,b,c:array[1..1000000]of longint;
 n,m,i,j:longint;
begin
 assign(input,'pelmeni.in');
 assign(output,'pelmeni.out');
 reset(input); rewrite(output);
 readln(n,m);
 for i:=1 to n-1 do read(a[i]);readln(a[n]);
 for i:=1 to m-1 do read(b[i]);readln(b[m]);
 for j:=1 to m do
  if  b[j]=1 then c[1]:=n else if b[j]=b[j-1]then c[j]:=c[j-1]
   else
  for i:=1 to n do
 if a[i]<b[j] then c[j]:=c[j]+a[i] else c[j]:=c[j]+b[j];
 for j:=1 to m-1 do write(c[j],' ');writeln(c[m]);
end.