#include <bits/stdc++.h>
using namespace std;
long long n, k, b, c, a[200005];
vector<long long> rem[5], rem1[5], sum[5], sum1[5];
void rotat() {
  swap(rem1[0], rem[4]);
  swap(sum1[0], sum[4]);
  for (long long i = 4; i > 0; --i) {
    swap(sum[i], sum[i - 1]);
    swap(rem[i], rem[i - 1]);
  }
  swap(rem[0], rem1[0]);
  swap(sum[0], sum1[0]);
}
int main() {
  cin >> n >> k >> b >> c;
  for (long long i = 1; i <= n; ++i) scanf("%I64d", a + i);
  sort(a + 1, a + 1 + n);
  if (b >= 5 * c) {
    long long sum = 0;
    for (long long i = 1; i < k; ++i) sum += a[i];
    long long mn = 1e18;
    for (long long i = k; i <= n; ++i) {
      sum += a[i];
      mn = min(mn, a[i] * k - sum);
      sum -= a[i - k + 1];
    }
    cout << mn * c << endl;
    return 0;
  }
  long long mn = 1e17;
  for (long long i = n; i > 0; --i) {
    a[i] -= a[1];
  }
  long long st[5] = {0};
  for (long long l = 0; l < 5; ++l) {
    for (long long i = 0; i < 5; ++i) {
      rem[i].clear();
      st[i] = 0;
    }
    long long sum = 0;
    for (long long i = 1; i < k; ++i) {
      rem[a[i] % 5].push_back(a[i]);
      sum += a[i];
    }
    for (long long i = k; i <= n; ++i) {
      long long now = ((a[i] + 4) / 5) * 5;
      rem[a[i] % 5].push_back(a[i]);
      sum += a[i];
      long long ans = 0, num = 0;
      for (long long j = 0; j < 5; ++j) {
        if (rem[j].empty()) continue;
        num += (rem[j].size() - st[j]) * ((5 - j) % 5);
      }
      mn = min(mn, (k * now - sum - num) / 5 * b + num * c);
      long long cost = 0, ind = 0;
      for (long long j = 0; j < 5; ++j) {
        if (rem[j].size() == st[j]) continue;
        if (cost < b * ((now - rem[j][st[j]]) / 5) + c * ((5 - j) % 5)) {
          cost = b * ((now - rem[j][st[j]]) / 5) + c * ((5 - j) % 5);
          ind = j;
        }
      }
      sum -= rem[ind][st[ind]];
      ++st[ind];
    }
    for (long long i = 1; i <= n; ++i) ++a[i];
  }
  cout << mn << endl;
}
