// version1
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long c1, c2;
long long con[1000007];
long long res;
long long aktual;
vector <long long> pos[5];
queue <long long> val[5];
int w;
long long p;
inline long long calc(long long a, long long b)
{
return ((b-a)%5)*c2+((b-a)/5)*c1;
}
int main()
{
res=1000000000;
res*=res;
scanf("%d%d", &n, &k);
scanf("%lld%lld", &c1, &c2);
c1=min(c1, 5*c2);
for (int i=1; i<=n; i++)
{
scanf("%lld", &con[i]);
con[i]+=1000000001;
}
sort(con+1, con+n+1);
for (int i=k; i<=n; i++)
{
for (int j=0; j<5; j++)
{
pos[(con[i]+j)%5].push_back(con[i]+j);
}
}
for (int h=0; h<5; h++)
{
sort(pos[h].begin(), pos[h].end());
for (int i=0; i<5; i++)
{
while(!val[i].empty())
val[i].pop();
}
w=0;
aktual=0;
for (int i=0; i<pos[h].size(); i++)
{
if (i)
aktual+=c1*min(w, k)*(pos[h][i]-pos[h][i-1])/5;
while(w<n && con[w+1]<=pos[h][i])
{
w++;
val[con[w]%5].push(con[w]);
aktual+=calc(con[w], pos[h][i]);
if (w>k)
{
p=0;
for (int j=0; j<5; j++)
{
if (!val[j].empty())
{
p=max(p, calc(val[j].front(), pos[h][i]));
}
}
for (int j=0; j<5; j++)
{
if (!val[j].empty() && calc(val[j].front(), pos[h][i])==p)
{
aktual-=p;
val[j].pop();
break;
}
}
}
}
if (w>=k)
{
res=min(res, aktual);
}
}
}
printf("%lld\n", res);
return 0;
}
//version2
import java.io.*;
import java.util.*;
public class E_bm_ac {
FastScanner in;
PrintWriter out;
long plus1, plus5;
void solve() {
int n = in.nextInt();
int k = in.nextInt();
plus5 = in.nextInt();
plus1 = in.nextInt();
plus5 = Math.min(plus5, plus1 * 5);
int[] t = new int[n];
for (int i = 0; i < n; i++) {
t[i] = in.nextInt();
}
Arrays.sort(t);
long result = Long.MAX_VALUE;
for (int mod5 = 0; mod5 < 5; mod5++) {
PriorityQueue<Integer> pq = new PriorityQueue<Integer>(10,
new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
long c1 = getCost(o1);
long c2 = getCost(o2);
return -Long.compare(c1, c2);
}
});
lastValue = Integer.MIN_VALUE;
long curCost = 0;
for (int i = 0; i < n; i++) {
int nextValue = t[i];
while (((nextValue % 5) + 5) % 5 != mod5) {
nextValue++;
}
curCost += pq.size() * 1L * ((nextValue - lastValue) / 5) * plus5;
lastValue = nextValue;
pq.add(t[i]);
curCost += getCost(t[i]);
if (pq.size() > k) {
Integer rem = pq.poll();
curCost -= getCost(rem);
}
if (pq.size() == k && curCost < result) {
result = curCost;
}
}
}
out.println(result);
}
int lastValue;
long getCost(long from) {
long d = lastValue - from;
return (d % 5) * plus1 + (d / 5) * plus5;
}
void run() {
try {
in = new FastScanner(new File("E.in"));
out = new PrintWriter(new File("E.out"));
solve();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
void runIO() {
in = new FastScanner(System.in);
out = new PrintWriter(System.out);
solve();
out.close();
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(File f) {
try {
br = new BufferedReader(new FileReader(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public FastScanner(InputStream f) {
br = new BufferedReader(new InputStreamReader(f));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (s == null)
return null;
st = new StringTokenizer(s);
}
return st.nextToken();
}
boolean hasMoreTokens() {
while (st == null || !st.hasMoreTokens()) {
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (s == null)
return false;
st = new StringTokenizer(s);
}
return true;
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
public static void main(String[] args) {
new E_bm_ac().runIO();
}
}