program ex;
type
ss=array[1..1000000]of longint;
var
a,f:ss;
n,k,c:longint;
f1,f2:text;
max,min:longint;
procedure init;
var
i,j:longint;
begin
max:=0;min:=maxlongint;
assign(f1,'divide.in');
assign(f2,'divide.out');
reset(f1);
rewrite(f2);
readln(f1,n,k,c);
for i:=1 to n do
begin
read(f1,a[i]);
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
close(f1);
end;
procedure main;
var
i,j:longint;
x,y:longint;
begin
x:=0;
y:=0;
if c*k<c+(max-min)*(max-min) then f[k]:=c*k
else f[k]:=c+(max-min)*(max-min);
for i:=k+1 to n do
begin
x:=f[i-1]+c*(i-k);
y:=f[i-1]+c+(max-min)*(max-min);
if x<y then f[i]:=x
else f[i]:=y;
end;
writeln(f2,f[n]);
end;
begin
init;
main;
close(f2);
end.