#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
priority_queue<long long> q[5];
long long sum[5];
int bas[5], ar[N];
int main() {
  int v, u, n, k, b, c, i, j;
  cin >> n >> k >> b >> c;
  for (i = 1; i <= n; ++i) scanf("%d", &ar[i - 1]);
  sort(ar, ar + n);
  u = ar[k - 1];
  long long f = min(b, 5 * c), temp, t, ret = 1e18, w;
  for (i = 0; i < 5; ++i) {
    v = ((u + i) % 5 + 5) % 5;
    bas[v] = u + i;
  }
  for (i = 0; i < k; ++i) {
    for (j = 0; j < 5; ++j) {
      v = ((u + j) % 5 + 5) % 5;
      temp = (u + j - ar[i]);
      b = temp % 5;
      temp /= 5;
      t = (long long)c * b + temp * f;
      sum[v] += t;
      q[v].push(t);
    }
  }
  for (i = 0; i < 5; ++i) ret = min(ret, sum[i]);
  for (i = k; i < n; ++i)
    for (j = 0; j < 5; ++j) {
      v = ((ar[i] + j) % 5 + 5) % 5;
      w = (ar[i] + j - bas[v]) / 5;
      t = (long long)j * c - w * f;
      if (q[v].top() > t) {
        temp = sum[v] - q[v].top() + t;
        temp += w * k * f;
        ret = min(ret, temp);
        temp = sum[v] - q[v].top() + t;
        sum[v] = temp;
        q[v].pop();
        q[v].push(t);
      }
    }
  cout << ret << endl;
}
