#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200200;
using ll = long long;
int N, K;
int B, C;
int A[MAXN];
int go[MAXN];
int cost[MAXN];
int main() {
  ios_base::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);
  ll ans = 1e18;
  for (int r = 0; r < 5; ++r) {
    for (int i = 0; i < N; ++i) {
      int delta = ((r - A[i]) % 5 + 5) % 5;
      go[i] = A[i] + delta;
      cost[i] = delta * C;
    }
    multiset<ll> ms;
    ll offset = 0;
    ll tot = 0;
    for (int i = 0; i < N; ++i) {
      if (i > 0 && go[i] > go[i - 1]) {
        ll delta = ll(go[i] - go[i - 1]) / 5 * B;
        offset += delta;
        tot += ll(ms.size()) * delta;
      }
      ms.emplace(-offset + cost[i]);
      tot += cost[i];
      if (ms.size() > K) {
        auto it = (--ms.end());
        tot -= (*it + offset);
        ms.erase(it);
      }
      if (ms.size() == K) ans = min(ans, tot);
    }
  }
  cout << ans << "\n";
  return 0;
}
