#include <bits/stdc++.h>
using namespace std;
const int N = 200002;
long long sum, ans, nd, T;
priority_queue<long long> q;
int n, k, b, c, t[N], i, j;
int main() {
  scanf("%d%d%d%d", &n, &k, &b, &c), ans = 1e18;
  b = min(b, c * 5);
  for (i = 1; i <= n; i++) scanf("%d", &t[i]);
  sort(t + 1, t + n + 1);
  for (i = 0; i < 5; i++) {
    T = 2e9 + i;
    while (!q.empty()) q.pop();
    sum = 0;
    for (j = 1; j <= n; j++) {
      nd = (T - t[j]) / 5 * b + (T - t[j]) % 5 * c;
      sum += nd;
      q.push(nd);
      if (q.size() > k) sum -= q.top(), q.pop();
      if (q.size() == k) ans = min(ans, sum - (T - t[j]) / 5 * b * k);
    }
  }
  printf("%lld", ans);
}
