#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  int neg = 1;
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * neg;
}
std::priority_queue<long long> q[10];
int a[200010], s[1000010];
long long sum[10];
int main() {
  int n = inp();
  int k = inp();
  int b = inp();
  int c = inp();
  b = std::min(b, c * 5);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = inp();
    for (int j = 0; j < 5; j++) s[++cnt] = a[i] + j;
  }
  std::sort(s + 1, s + cnt + 1);
  std::sort(a + 1, a + n + 1);
  cnt = std::unique(s + 1, s + cnt + 1) - s - 1;
  int cur = 1;
  long long ans = 1e18;
  for (int i = 1; i <= cnt; i++) {
    int t = (int)(1e9 + s[i]) % 5;
    while (cur <= n && a[cur] <= s[i]) {
      for (int j = 0; j < 5; j++) {
        long long delta = (1e9 + j - a[cur]);
        long long cc = (delta / 5) * b + (delta % 5) * c;
        q[j].push(cc);
        sum[j] += cc;
      }
      cur++;
    }
    while (q[t].size() > k) {
      sum[t] -= q[t].top();
      q[t].pop();
    }
    if (q[t].size() == k)
      ans = std::min(ans, sum[t] - (((long long)(1e9 + t - s[i])) / 5) * b * k);
  }
  std::cout << ans << std::endl;
}
