#include <bits/stdc++.h>
using namespace std;
int t[200500];
vector<int> v[5];
multiset<pair<long long, int> > st[5];
const long long mx = 1000000500;
long long sum[5], sum2[5];
int main() {
  ios_base::sync_with_stdio(0);
  long long n, k, b, c;
  cin >> n >> k >> b >> c;
  if (b >= 5 * c) {
    for (int i = 0; i < n; i++) cin >> t[i];
    sort(t, t + n);
    long long sum = 0;
    long long ans = 1e18;
    for (int i = 0; i < k; i++) sum += c * (mx - t[i]);
    for (int i = k; i < n; i++) {
      ans = min(ans, sum - k * (mx - t[i - 1]) * c);
      sum -= c * (mx - t[i - k]);
      sum += c * (mx - t[i]);
    }
    ans = min(ans, sum - k * (mx - t[n - 1]) * c);
    cout << ans;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  sort(t, t + n);
  pair<long long, int> pp;
  long long ans = 1e18;
  for (int i = 0; i < n; i++) {
    int ost = (t[i] % 5);
    if (ost < 0) ost += 5;
    for (int j = 0; j < 5; j++) {
      long long cost = ((mx + j - t[i]) / 5) * (long long)b +
                       ((5 + j - ost) % 5) * (long long)c;
      st[j].insert(make_pair(cost, t[i]));
      sum[j] += cost;
      if (st[j].size() > k) {
        pp = *(st[j].rbegin());
        st[j].erase(st[j].find(pp));
        sum[j] -= pp.first;
      }
    }
    for (int j = 0; j < 5; j++) {
      if (st[(ost + j) % 5].size() == k)
        ans = min(ans, sum[(ost + j) % 5] -
                           k * (mx + (ost + j) % 5 - t[i] - j) / 5 * b);
    }
  }
  cout << ans;
  return 0;
}
