#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200500;
long long arr[MAXN];
long long n, k, b, c;
void stup() {
  long long res;
  long long sum = 0;
  for (int i = 0; i < k; ++i) sum += arr[i];
  res = k * arr[k - 1] - sum;
  for (int i = 0; i < n - k; ++i) {
    sum -= arr[i];
    sum += arr[i + k];
    res = min(res, k * arr[i + k] - sum);
  }
  cout << res * c;
}
void sol() {
  vector<long long> q(5 * n);
  vector<vector<long long> > query(5);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 5; ++j) q[i * 5 + j] = arr[i] + j;
  sort(q.begin(), q.end());
  q.resize(unique(q.begin(), q.end()) - q.begin());
  for (int i = 0; i < (int)q.size(); ++i) {
    query[(q[i] % 5 + 15) % 5].push_back(q[i]);
  }
  long long res = 1e18;
  for (int mod = 0; mod < 5; ++mod) {
    int ptr = 0;
    multiset<long long> pl;
    long long sum = 0;
    for (int i = 0; i < (int)query[mod].size(); ++i) {
      long long cur = query[mod][i];
      while (ptr != n && arr[ptr] <= cur) {
        long long dmod = (mod - arr[ptr] % 5 + 15) % 5;
        long long val = dmod * c - ((arr[ptr] + dmod) / 5) * b;
        sum += val;
        pl.insert(-val);
        if ((int)pl.size() > k) {
          sum += *pl.begin();
          pl.erase(pl.begin());
        }
        ptr++;
      }
      if ((int)pl.size() == k) {
        res = min(res, k * (cur / 5) * b + sum);
      }
    }
  }
  cout << res;
}
int main() {
  cin >> n >> k >> b >> c;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 0; i < n; ++i) arr[i] += (long long)1e9;
  sort(arr, arr + n);
  for (int i = 0; i < n - k + 1; ++i) {
    if (arr[i] == arr[i + k - 1]) {
      cout << 0;
      return 0;
    }
  }
  if (5 * c <= b)
    stup();
  else
    sol();
  return 0;
}
