#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long INF = 1e9;
int a[N], dis[N * 5];
long long sum[5];
long long ans = 1e18;
int n, k, b, c, cnt;
priority_queue<long long> Q[5];
int main() {
  scanf("%d%d%d%d", &n, &k, &b, &c);
  b = min(b, c * 5);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j < 5; j++) dis[cnt++] = a[i] + j;
  }
  sort(a + 1, a + n + 1), sort(dis, dis + cnt);
  cnt = unique(dis, dis + cnt) - dis;
  int now = 1;
  for (int i = 0; i < cnt; i++) {
    int x = dis[i], kind = (INF + x) % 5;
    long long cost;
    while (now <= n && a[now] <= x) {
      for (int j = 0; j < 5; j++) {
        cost = (INF + j - a[now]) / 5 * b + (INF + j - a[now]) % 5 * c;
        Q[j].push(cost);
        sum[j] += cost;
        if ((int)Q[j].size() > k) {
          sum[j] -= Q[j].top();
          Q[j].pop();
        }
      }
      now++;
    }
    long long y = (INF + kind - x) / 5 * b * k;
    if ((int)Q[kind].size() == k) ans = min(ans, sum[kind] - y);
  }
  printf("%lld\n", ans);
  return 0;
}
