#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct node {
  long long w, add;
} s[N];
int n, k;
long long ans = (1ll << 60), sum, b, c;
int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
bool cmp(const node a, const node b) { return a.w + a.add < b.w + b.add; }
int main() {
  int delta;
  n = read(), k = read(), b = read(), c = read();
  b = min(b, 5 * c);
  for (int i = 1; i <= n; ++i) s[i].w = read() + 1e9;
  for (int r = 0; r < 5; ++r) {
    for (int i = 1; i <= n; ++i) {
      delta = 0;
      while ((s[i].w + delta) % 5 != r) ++delta;
      s[i].add = delta;
    }
    priority_queue<long long> q;
    sort(s + 1, s + n + 1, cmp);
    sum = 0;
    for (int i = 1; i <= n; ++i) {
      long long aim = s[i].w + s[i].add;
      long long tmp = c * s[i].add - b * (s[i].w + s[i].add - r) / 5;
      sum += tmp;
      q.push(tmp);
      if (q.size() == k) {
        ans = min(ans, sum + b * k * (aim - r) / 5);
        sum -= q.top();
        q.pop();
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
