#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long n, k, b, c, a[N], nxt[5][N];
struct nu {
  int md, t;
  long long cost;
  bool operator<(struct nu y) const { return cost < y.cost; }
};
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> b >> c;
  b = min(b, 5 * c);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      nxt[((a[i] + j) % 5 + 5) % 5][i] = a[i] + j;
    }
  }
  long long res = 9e18;
  for (int m = 0; m < 5; m++) {
    long long cost = 0, sum = 0;
    priority_queue<nu> h;
    for (int i = 0; i < n; i++) {
      if (i < k) {
        sum += c * (nxt[m][i] - a[i]) - (nxt[m][i] - m) / 5 * b;
      } else {
        sum += c * (nxt[m][i] - a[i]) - (nxt[m][i] - m) / 5 * b;
        nu tmp = h.top();
        h.pop();
        sum -= tmp.cost;
      }
      h.push((nu){m, i, c * (nxt[m][i] - a[i]) - (nxt[m][i] - m) / 5 * b});
      if (i >= k - 1) {
        cost = k * (nxt[m][i] - m) / 5 * b + sum;
        res = min(res, cost);
      }
    }
  }
  cout << res << endl;
  return 0;
}
