#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
const int MAXN = 200117, MAXM = 1200117, C = 5, MAXX = 1000000120;
int n, k, a[MAXN], b, c, m, p[MAXM];
long long ans, s[C];
priority_queue<long long> q[C];
inline void add(int x) {
  int rx = ((x % C) + C) % C;
  for (int i = 0; i < C; i++) {
    int d = c * ((i < rx) ? (C + i - rx) : (i - rx));
    long long xx =
        d + 1LL * b *
                (((MAXX + i) - (x + ((i < rx) ? (C + i - rx) : (i - rx)))) / C);
    if (((int)(q[i]).size()) < k)
      s[i] += xx, q[i].push(xx);
    else if (q[i].top() > xx)
      s[i] -= q[i].top() - xx, q[i].pop(), q[i].push(xx);
  }
}
int main() {
  scanf("%d %d %d %d", &n, &k, &b, &c);
  b = min(b, 5 * c);
  for (int i = 0; i < n; scanf("%d", &a[i++]))
    ;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 5; j++) p[m++] = a[i] + j;
  sort(p, p + m);
  m = unique(p, p + m) - p;
  sort(a, a + n);
  ans = (2117117117117117117LL);
  for (int i = 0, j = 0; i < m; i++) {
    for (; j < n && p[i] >= a[j]; add(a[j++]))
      ;
    int t = ((p[i] % C) + C) % C;
    if (((int)(q[t]).size()) == k)
      ans = min(ans, s[t] - 1LL * k * b * (((MAXX + t) - p[i]) / C));
  }
  printf("%lld\n", ans);
  return 0;
}
