#include <bits/stdc++.h>
using namespace std;
long long n, k, b, c;
long long t[200010];
long long pointer[5][5];
vector<long long> bucket[5], psum[5];
long long getv(long long buck, long long pos) {
  if (pos == 0) return bucket[buck][0];
  return bucket[buck][pos] - bucket[buck][pos - 1];
}
long long getv(long long buck, long long a, long long b) {
  if (a == 0) return bucket[buck][b];
  return bucket[buck][b] - bucket[buck][a - 1];
}
long long getcost(long long tim, long long buck, long long pos) {
  long long j = getv(buck, pos);
  long long cost = (tim / 5 - j) * b;
  if (buck < tim % 5) {
    cost += ((tim % 5) - buck) * c;
  } else if (buck > tim % 5) {
    cost -= b;
    cost += (((tim % 5) - buck) + 5) * c;
  }
  return cost;
}
long long test(long long tim) {
  long long bnum = tim % 5;
  long long total = 0;
  priority_queue<pair<long long, long long> > x;
  for (long long j = 0; j < 5; j++) {
    total += bucket[j].size() - pointer[bnum][j];
    if (pointer[bnum][j] != bucket[j].size())
      x.push(make_pair(getcost(tim, j, pointer[bnum][j]), j));
  }
  while (total > k) {
    total--;
    long long c = x.top().second;
    x.pop();
    pointer[bnum][c]++;
    if (pointer[bnum][c] != bucket[c].size())
      x.push(make_pair(getcost(tim, c, pointer[bnum][c]), c));
  }
  long long cost = 0;
  for (long long i = 0; i < 5; i++) {
    long long s = bucket[i].size() - pointer[bnum][i];
    if (s > 0) {
      cost +=
          b * (s * (tim / 5) - getv(i, pointer[bnum][i], bucket[i].size() - 1));
    }
  }
  long long p = bnum;
  for (long long i = 1; i <= 4; i++) {
    p += 4;
    p %= 5;
    long long s = bucket[p].size() - pointer[bnum][p];
    if (p > bnum) cost -= s * b;
    cost += s * i * c;
  }
  return cost;
}
int32_t main() {
  cin >> n >> k >> b >> c;
  for (long long i = 0; i < n; i++) {
    cin >> t[i];
    t[i] += 1e9;
  }
  sort(t, t + n);
  if (c * 5 <= b) {
    long long ans = 0;
    for (long long i = 0; i < k; i++) ans += t[k - 1] - t[i];
    cout << ans * c << "\n";
    return 0;
  }
  long long ans = 4e18;
  for (long long i = 0; i < n; i++) {
    bucket[t[i] % 5].push_back(t[i] / 5);
    if (bucket[t[i] % 5].size() > 1)
      bucket[t[i] % 5].back() += *(bucket[t[i] % 5].end() - 2);
    if (i >= k - 1) {
      for (long long j = 0; j < 5; j++) ans = min(ans, test(t[i] + j));
    }
  }
  cout << ans << "\n";
  return 0;
}
