#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e9 + 7;
const long long LINF = (long long)2e18 + 7;
long long N, K, B, C;
vector<pair<long long, long long>> A;
long long go(vector<pair<long long, long long>> &V) {
  sort(V.begin(), V.end());
  long long ans = 8e18;
  long long cursum = 0;
  for (long long i = 0; i < K; i++)
    cursum += (V[K - 1].second - V[i].second) * B + V[i].first;
  ans = min(ans, cursum);
  for (long long l = 1; l <= N - K; l++) {
    long long r = l + K - 1;
    long long d = V[r].second - V[r - 1].second;
    cursum += d * K * B;
    cursum -= (V[r].second - V[l - 1].second) * B;
    cursum += V[r].first;
    cursum -= V[l - 1].first;
    ans = min(ans, cursum);
  }
  return ans;
}
int main() {
  cin >> N >> K >> B >> C;
  for (long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    a += 1e9;
    A.push_back(make_pair(0ll, a));
  }
  vector<pair<long long, long long>> Nw;
  swap(B, C);
  long long ans = go(A);
  swap(B, C);
  for (long long i = 0; i < 5; i++) {
    Nw.clear();
    Nw.reserve(N);
    long long mx = 0;
    for (long long j = 0; j < N; j++) {
      long long k =
          (A[j].second - i + ((A[j].second - i) > 0 ? 4ll : 0ll)) / 5ll;
      mx = max(mx, k);
      long long nh = k * 5ll + i;
      Nw.push_back(make_pair(k, (nh - A[j].second) * C));
    }
    long long curs = 0;
    long long add = 0;
    sort(Nw.begin(), Nw.end());
    multiset<long long> S;
    for (long long j = 0; j < K; ++j) {
      S.insert(Nw[j].second + (Nw[K - 1].first - Nw[j].first) * B);
      curs += Nw[j].second + (Nw[K - 1].first - Nw[j].first) * B;
    }
    ans = min(ans, curs);
    for (long long j = K; j < N; ++j) {
      long long d = Nw[j].first - Nw[j - 1].first;
      add += 1ll * d * B;
      curs += 1ll * d * B * K;
      if (*S.rbegin() + add > Nw[j].second) {
        curs -= *S.rbegin() + add;
        curs += 1ll * Nw[j].second;
        S.erase(S.find(*S.rbegin()));
        S.insert(1ll * Nw[j].second - add);
      }
      ans = min(ans, curs);
    }
  }
  cout << ans << "\n";
  return 0;
}
