var a,b:array [1..1000100] of longint;
    i,j,m,n:longint;
    ans:int64;
procedure qs1(l,r:longint);
var i,j,k,c:longint;
begin
    i:=l; j:=r; k:=a[(l+r) div 2];
     repeat
      while (a[i]<k) do inc(i);
      while (a[j]>k) do dec(j);
       if (i<=j) then 
        begin
          c:=a[i]; a[i]:=a[j]; a[j]:=c;
           inc(i); dec(j);
        end;
     until i>j;
    if (i<r) then qs1(i,r);
    if (l<j) then qs1(l,j);
end;
procedure qs2(l,r:longint);
var i,j,k,c:longint;
begin
    i:=l; j:=r; k:=b[(l+r) div 2];
     repeat
      while (b[i]<k) do inc(i);
      while (b[j]>k) do dec(j);
       if (i<=j) then 
        begin
          c:=b[i]; b[i]:=b[j]; b[j]:=c;
           inc(i); dec(j);
        end;
     until i>j;
    if (i<r) then qs2(i,r);
    if (l<j) then qs2(l,j);
end;
begin
  assign(input,'E.in');   reset(input);
  assign(output,'E.out'); rewrite(output);
   read(n,m);    ans:=0;
    for i:=1 to n do
     read(a[i]);
    for i:=1 to m do
     read(b[i]);
    qs1(1,n); qs2(1,m);
   if (n>=m) then
    begin
     for i:=m downto 1 do
       ans:=ans+a[m-i+1]*b[i];
      end else
    begin
     for i:=n downto 1 do
      ans:=ans+b[n-i+1]*a[i];
    end;
     if (n>m) then write(m,' ') else write(n,' '); writeln(ans);
  close(output);
end.