#include <bits/stdc++.h>
using namespace std;
void errDebug() {}
template <typename T, typename... Args>
void errDebug(T a, Args... args) {
  cerr << a << ' ';
  errDebug(args...);
}
long long n, k, b, c;
long long a[200100];
long long solve() {
  sort(a, a + n);
  if (c * 5 <= b) {
    long long ans = 1e18;
    long long res = 0;
    for (int(i) = (0); (i) < (k); ++(i)) res += (a[k - 1] - a[i]);
    ans = res;
    for (int(i) = (k); (i) < (n); ++(i)) {
      res -= (a[i - 1] - a[i - k - 1]);
      res += (k - 1) * (a[i] - a[i - 1]);
      ans = min(ans, res);
    }
    return ans * c;
  }
  long long res = 1e18;
  for (int(i) = (0); (i) < (5); ++(i)) {
    multiset<long long, greater<long long> > uset;
    long long tot = 0;
    for (int(j) = (0); (j) < (n); ++(j)) {
      long long val = a[j];
      while (val % 5 != i) val++;
      long long cost = (val - a[j]) * c;
      tot += (cost - (val / 5) * b);
      uset.insert(cost - (val / 5) * b);
      if (uset.size() > k) {
        long long v = *uset.begin();
        uset.erase(uset.begin());
        tot -= v;
      }
      if (uset.size() == k) {
        res = min(res, k * (val / 5) * b + tot);
      }
    }
  }
  return res;
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(false);
  cin >> n >> k >> b >> c;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
    a[i] += 1000000000;
  }
  cout << solve() << endl;
  return 0;
}
