#include <bits/stdc++.h>
using namespace std;
struct node {
  long long val, add;
} v[200005];
int n, k;
long long b, c, ans = 1ll << 60;
bool cmp(node x, node y) { return x.val + x.add < y.val + y.add; }
int main() {
  scanf("%d %d %lld %lld", &n, &k, &b, &c);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &v[i].val);
    v[i].val += 1e9;
  }
  b = min(b, c * 5);
  for (int r = 0; r <= 4; r++) {
    for (int i = 1; i <= n; i++) {
      int j = 0;
      while ((v[i].val + j) % 5 != r) j++;
      v[i].add = j;
    }
    sort(v + 1, v + n + 1, cmp);
    priority_queue<long long> q;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      long long aim = v[i].val + v[i].add;
      long long temp = c * v[i].add - b * (v[i].val + v[i].add - r) / 5;
      sum += temp;
      q.push(temp);
      if (q.size() == k) {
        ans = min(ans, sum + b * (aim - r) / 5 * k);
        sum -= q.top();
        q.pop();
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
