program ristorante;
const maxN=100000;
maxM=200000;
type elenco=array [1..maxN] of longint;
var N,M,D,i, guadagno, ricavo:longint;
costi:array[1..maxN] of longint;
Procedure scambia (var a,b: longint);
var x:longint;
begin
x:=a;
a:=b;
b:=x;
end;
Procedure ordinamento (estremoi,estremos: longint; var v : elenco; ordinato:boolean);
var inf, sup, medio:longint;
pivot :longint;
begin
inf:=estremoi;
sup:=estremos;
medio:= (estremoi+estremos) div 2;
pivot:=v[medio];
repeat
if (ordinato) then
begin
while (v[inf]<pivot) do inf:=inf+1;
while (v[sup]>pivot) do sup:=sup-1;
end;
if inf<=sup then
begin
scambia(v[inf],v[sup]);
inf:=inf+1;
sup:=sup-1;
end;
until inf>sup;
if (estremoi<sup) then ordinamento(estremoi,sup,v,ordinato);
if (inf<estremos) then ordinamento(inf,estremos,v,ordinato);
end;
begin
readln(N,D);
ricavo:=0; guadagno:=0;
for i:=1 to N do begin read(costi[i]); ricavo:=ricavo+costi[i]; end; readln;
readln(M);
ordinamento (1,N,costi,true);
if M>=N then guadagno:=ricavo-(M-N)*D
else for i:=1 to M do guadagno:=guadagno+costi[i];
writeln(guadagno);
end.
cHJvZ3JhbSByaXN0b3JhbnRlOwpjb25zdCBtYXhOPTEwMDAwMDsKICAgICAgbWF4TT0yMDAwMDA7CnR5cGUgZWxlbmNvPWFycmF5IFsxLi5tYXhOXSBvZiBsb25naW50OyAgICAgIAp2YXIgTixNLEQsaSwgZ3VhZGFnbm8sIHJpY2F2bzpsb25naW50OwogICAgY29zdGk6YXJyYXlbMS4ubWF4Tl0gb2YgbG9uZ2ludDsKICAgIApQcm9jZWR1cmUgc2NhbWJpYSAodmFyIGEsYjogbG9uZ2ludCk7CnZhciB4OmxvbmdpbnQ7CmJlZ2luCiAgIHg6PWE7CiAgIGE6PWI7CiAgIGI6PXg7CmVuZDsgIApQcm9jZWR1cmUgb3JkaW5hbWVudG8gKGVzdHJlbW9pLGVzdHJlbW9zOiBsb25naW50OyB2YXIgdiA6IGVsZW5j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