#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int n, k;
long long b, c;
long long A[maxn + 1];
struct data {
  long long cost, num;
} a[maxn + 1][5];
struct heap {
  data que[maxn + 1];
  int nums;
  long long res, sum;
  heap() {
    memset(que, 0, sizeof(que));
    nums = 0;
    res = sum = 0ll;
  }
  void push(data x) {
    que[++nums] = x;
    for (int i = nums; i > 1; i = i / 2) {
      int p = i / 2;
      if (que[p].cost + (res - que[p].num) / 5 * b >
          que[i].cost + (res - que[i].num) / 5 * b)
        break;
      swap(que[i], que[p]);
    }
  }
  data top() { return que[1]; }
  int pop() {
    long long val = res;
    que[1].num = que[nums].num, que[1].cost = que[nums].cost;
    nums--;
    for (int i = 1; i * 2 <= nums;) {
      int lc = i * 2, rc = i * 2 + 1;
      if (i * 2 + 1 <= nums && que[lc].cost + (val - que[lc].num) / 5 * b <
                                   que[rc].cost + (val - que[rc].num) / 5 * b)
        lc = rc;
      if (que[lc].cost + (val - que[lc].num) / 5 * b <
          que[i].cost + (val - que[i].num) / 5 * b)
        break;
      swap(que[i], que[lc]);
      i = lc;
    }
  }
};
data make_data(long long cost, long long num) {
  data x;
  x.cost = cost, x.num = num;
  return x;
}
void init() {
  scanf("%d%d%lld%lld", &n, &k, &b, &c);
  b = min(b, 5 * c);
  for (int i = 1; i <= n; i++) scanf("%lld", A + i);
  sort(A + 1, A + 1 + n);
  for (int i = 1; i <= n; i++) {
    int temp = (A[i] % 5 + 5) % 5;
    a[i][temp].cost = 0;
    a[i][temp].num = A[i];
    for (int j = 1; j <= 4; j++) {
      temp = (temp + 1) % 5;
      a[i][temp].cost = c * j;
      a[i][temp].num = A[i] + j;
    }
  }
}
heap q[5];
long long pre[maxn + 1];
void solve() {
  long long ans = 0x7F7F7F7F7F7F7F7F;
  for (int i = 0; i <= 4; i++) {
    q[i].res = a[1][i].num;
    for (int j = 1; j <= k; j++) {
      q[i].sum += q[i].nums * ((a[j][i].num - q[i].res) / 5 * b) + a[j][i].cost;
      q[i].res = max(q[i].res, a[j][i].num);
      q[i].push(a[j][i]);
    }
    ans = min(ans, q[i].sum);
  }
  for (int i = 0; i <= 4; i++)
    for (int j = k + 1; j <= n; j++) {
      q[i].sum -= (q[i].res - q[i].top().num) / 5 * b + q[i].top().cost;
      q[i].pop();
      q[i].sum += q[i].nums * ((a[j][i].num - q[i].res) / 5 * b) + a[j][i].cost;
      q[i].res = max(q[i].res, a[j][i].num);
      q[i].push(a[j][i]);
      ans = min(ans, q[i].sum);
    }
  printf("%lld\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
