#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
int a[200010], dis[1000010];
long long sum[5];
long long ans;
int n, k, b, c, num;
priority_queue<long long> q[5];
int main() {
  scanf("%d%d%d%d", &n, &k, &b, &c);
  ans = 1e18;
  b = min(b, c * 5);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    for (int j = 0; j < 5; ++j) dis[num++] = a[i] + j;
  }
  sort(a + 1, a + 1 + n);
  sort(dis, dis + num);
  num = unique(dis, dis + num) - dis;
  int now = 1;
  for (int i = 0; i < num; ++i) {
    int x = dis[i], ks = (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 + ks - x) / 5 * b * k;
    if (q[ks].size() == k) ans = min(ans, sum[ks] - y);
  }
  printf("%lld\n", ans);
}
