#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
long long n, k, b, c, ans = 0x7f7f7f7f7f7f7f7f, cnt;
pair<long long, long long> a[200010];
inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first + a.second < b.first + b.second;
}
priority_queue<long long> q;
signed main() {
  n = read();
  k = read();
  b = read();
  c = read();
  b = min(b, c * 5);
  for (long long i = 1; i <= n; ++i) a[i].first = read() + 1000000000;
  for (long long _ = 0; _ < 5; ++_) {
    for (long long i = 1; i <= n; ++i)
      a[i].second = (_ - a[i].first % 5 + 5) % 5;
    sort(a + 1, a + n + 1, cmp);
    while (!q.empty()) q.pop();
    cnt = 0;
    for (long long i = 1; i <= n; ++i) {
      long long x = a[i].first, y = a[i].second;
      long long z = c * y - b * (x + y - _) / 5;
      cnt += z;
      q.push(z);
      if (q.size() == k) {
        ans = min(ans, cnt + b * (x + y - _) / 5 * k);
        cnt -= q.top();
        q.pop();
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
