#include <bits/stdc++.h>
using namespace std;
int a[200010], b[200010], c[200010];
int n, m;
long long B, C;
int main() {
  scanf("%d %d %I64d %I64d", &n, &m, &B, &C);
  B = min(B, 5 * C);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  long long ans = (1LL << 62);
  for (int r = 0; r < 5; r++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] % 5 != r) {
        c[i] = (r - (a[i] % 5) + 5) % 5;
      } else
        c[i] = 0;
      b[i] = (a[i] + c[i] - r) / 5;
    }
    long long sum = 0;
    priority_queue<long long, vector<long long> > q;
    for (int i = 0; i < m; i++) {
      long long tp = C * c[i] + B * (b[m - 1] - b[i]);
      q.push(tp);
      sum += tp;
    }
    if (ans > sum) ans = sum;
    long long D = 0;
    for (int i = m; i < n; i++) {
      long long mx = q.top();
      q.pop();
      sum -= (mx + D);
      sum += B * (m - 1) * (b[i] - b[i - 1]) + C * c[i];
      D = (b[i] - b[m - 1]) * B;
      q.push(c[i] * C - D);
      if (ans > sum) ans = sum;
    }
  }
  cout << ans << endl;
}
