{ Free Pascal }
program pelmeni;
var res: int64;
    b,i,j,n,m,x: longint;
    a: array [1..100000] of longint;

begin
 assign (input, 'pelmeni.in');
 assign (output, 'pelmeni.out');
 reset (input);
 rewrite (output);
 readln(n,m);
 b:=-1;

 for i:=1 to n do read (a[i]);
 for i:=1 to m do
 begin
   read (x);
   if b<>x then
   begin
   res:=0;
   for j:=1 to n do
   begin
     if x>a[j] then res:=res+a[j];
     if x<=a[j] then
     begin
       res:=res+(x*(n-j+1));
       break;
     end;
   end;
   end;
   write(res);
   if i<m then write(' ');
   b:=x;
 end;
 writeln;
end.







