#include <bits/stdc++.h>
using namespace std;
struct sth {
  long long v, c;
} m[5][200010], h[5][200010];
long long n, k, b, c, tmp, xl;
long long minh = 9223372036854775807, tc;
long long v[200010];
long long pre[200010];
long long ma[5], l[5], Cos[5];
bool cmp2(sth x, sth y) {
  return x.c + (ma[xl] - x.v) / 5 * b < y.c + (ma[xl] - y.v) / 5 * b;
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &k, &b, &c);
  for (int i = 1; i <= n; i++) scanf("%I64d", &v[i]);
  sort(v + 1, v + 1 + n);
  for (int i = 1; i <= n; i++) {
    tmp = (v[i] % 5 + 5) % 5;
    tc = 0;
    m[tmp][i].v = v[i];
    m[tmp][i].c = 0;
    for (int j = 1; j <= 4; j++) {
      tmp = (tmp + 1) % 5;
      tc += c;
      m[tmp][i].v = v[i] + j;
      m[tmp][i].c = tc;
    }
  }
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + v[i];
    if (i >= k) {
      tc = v[i] * k - (pre[i] - pre[i - k]);
      minh = min(tc * c, minh);
    }
  }
  for (int j = 0; j <= 4; j++) {
    ma[j] = m[j][1].v;
    for (int i = 1; i <= k; i++) {
      Cos[j] += l[j] * ((m[j][i].v - ma[j]) / 5 * b) + m[j][i].c;
      ma[j] = max(ma[j], m[j][i].v);
      l[j]++;
      h[j][l[j]] = m[j][i];
      xl = j;
      push_heap(h[j] + 1, h[j] + l[j] + 1, cmp2);
    }
    minh = min(minh, Cos[j]);
  }
  for (int j = 0; j <= 4; j++)
    for (int i = k + 1; i <= n; i++) {
      xl = j;
      pop_heap(h[j] + 1, h[j] + l[j] + 1, cmp2);
      Cos[j] -= (ma[j] - h[j][k].v) / 5 * b + h[j][k].c;
      Cos[j] += (k - 1) * ((m[j][i].v - ma[j]) / 5 * b) + m[j][i].c;
      ma[j] = max(ma[j], m[j][i].v);
      h[j][k] = m[j][i];
      push_heap(h[j] + 1, h[j] + k + 1, cmp2);
      minh = min(minh, Cos[j]);
    }
  printf("%I64d", minh);
  return 0;
}
