program juxingfenge;
var
n,m,i,t:longint;
a:array[1..4000]of longint;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
assign (input,'cut.in');
reset (input);
assign (output,'cut.out');
rewrite (output);
readln (n,m);
for i:=1 to n+m-2 do
readln (a[i]);
sort(1,n+m-2);
for i:=n+m-2 downto 1 do
t:=t+a[i]*i;
writeln (t);
close (input);
close (output)
end.