#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
void precalc() {}
const long long inf = 1.01e18;
const int maxn = 2e5 + 10;
int n, k, b, c;
int t[maxn];
bool read() {
  if (scanf("%d%d%d%d", &n, &k, &b, &c) < 4) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &t[i]);
  }
  return true;
}
void solve() {
  sort(t, t + n);
  b = min(b, 5 * c);
  long long ans = inf;
  for (int rem = 0; rem < 5; ++rem) {
    multiset<long long> q;
    long long csum = 0;
    for (int i = 0; i < n; ++i) {
      long long cost = 0;
      int ct = t[i];
      for (; (ct % 5 + 5) % 5 != rem; cost += c, ++ct)
        ;
      cost -= (long long)((ct - rem) / 5) * b;
      q.insert(cost);
      csum += cost;
      if (((int)(q).size()) > k) {
        auto it = q.end();
        it--;
        csum -= (*it);
        q.erase(it);
      }
      if (((int)(q).size()) == k) {
        ans = min(ans, csum + (long long)k * ((ct - rem) / 5) * b);
      }
    }
  }
  assert(ans >= 0);
  printf("%I64d\n", ans);
}
int main() {
  srand(rdtsc());
  precalc();
  while (true) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
