#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 20;
int n, K, B, C;
long long a[MAXN];
pair<long long, long long> b[MAXN];
long long solve(pair<long long, long long>* b, long long B, long long C) {
  priority_queue<pair<long long, int> > q;
  int cnt = 0;
  long long cur = 0;
  for (int i = 1; i <= K; i++) {
    cur += b[i].second * C + (b[i].first - b[i - 1].first) * B * cnt++;
    q.push(make_pair(b[i].second * C + (b[1].first - b[i].first) * B, i));
  }
  long long ans = cur;
  for (int i = K + 1; i <= n; i++) {
    int j = q.top().second;
    q.pop();
    cnt--;
    cur -= b[j].second * C + (b[i - 1].first - b[j].first) * B;
    cur += b[i].second * C + (b[i].first - b[i - 1].first) * B * cnt++;
    q.push(make_pair(b[i].second * C + (b[1].first - b[i].first) * B, i));
    ans = min(ans, cur);
  }
  return ans;
}
int main() {
  scanf("%d%d%d%d", &n, &K, &B, &C);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += 1e9;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) b[i].first = a[i], b[i].second = 0;
  long long ans = solve(b, C, 0);
  for (int i = 0; i < 5; i++) {
    for (int j = 1; j <= n; j++) {
      b[j].second = ((i - (a[j] % 5)) + 5) % 5;
      b[j].first = (a[j] + b[j].second) / 5;
    }
    ans = min(ans, solve(b, B, C));
  }
  printf("%lld\n", ans);
}
