program criminala;
var
a:array [1..50000] of longint;
h1,h2:array [1..1000] of longint;
n,m,max,min:longint;
f1,f2:text;
procedure init;
var i:longint;
begin
assign(f1,'criminala.in'); reset(f1);
assign(f2,'criminala.out'); rewrite(f2);
readln(f1,n,m);
for i:=1 to m do begin
readln(f1,a[i]);
if a[i]>0 then inc(h1[a[i]])
else inc(h2[abs(a[i])]);
end;
close(f1);
max:=0;
min:=1001;
end;
procedure dfs(x,total:longint);
var r:longint;
begin
if x=n+1 then begin
if total>max then max:=total;
if total<min then min:=total;
end
else begin
for r:=1 to 2 do begin
if r=1 then begin
dfs(x+1,total+h2[x]);
end;
if r=2 then begin
dfs(x+1,total+h1[x]);
end;
end;
end;
end;
begin
init;
dfs(1,0);
writeln(f2,max);
writeln(f2,min);
close(f2);
end.