#include <bits/stdc++.h>
using namespace std;
long long ans = 1e18;
priority_queue<long long> q[5];
int n, k, b, c;
int v[200005];
long long sum[5];
int dis[5 * 200005], cnt;
int main() {
  scanf("%d%d%d%d", &n, &k, &b, &c);
  b = min(b, 5 * c);
  for (int i = 1; i <= n; i++) {
    scanf("%d", v + i);
    for (int j = 0; j <= 4; j++) dis[++cnt] = v[i] + j;
  }
  sort(v + 1, v + n + 1);
  sort(dis + 1, dis + cnt + 1);
  cnt = unique(dis + 1, dis + cnt + 1) - (dis + 1);
  int now = 1;
  for (int i = 1; i <= cnt; i++) {
    int aim = dis[i];
    int kind = (1000000000 + aim) % 5;
    long long cost;
    while (now <= n && v[now] <= aim) {
      for (int j = 0; j <= 4; j++) {
        cost = 1ll * (1000000000 - (v[now] - j)) / 5 * b +
               1ll * (1000000000 - (v[now] - j)) % 5 * c;
        q[j].push(cost);
        sum[j] += cost;
        if (int(q[j].size()) > k) {
          sum[j] -= q[j].top();
          q[j].pop();
        }
      }
      now++;
    }
    if (int(q[kind].size()) == k)
      ans = min(ans, sum[kind] - 1ll * (1000000000 - (aim - kind)) / 5 * b * k);
  }
  printf("%lld\n", ans);
  return 0;
}
