#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
void solve();
void precalc();
clock_t start;
int testNumber = 1;
bool todo = true;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  int testNum = 1;
  while (t--) {
    solve();
    ++testNumber;
  }
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
void precalc() {}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
long long n, k, b, c;
long long dist(long long from, long long to) {
  long long res = 0;
  long long rest_from = ((from % 5) + 5) % 5, rest_to = ((to % 5) + 5) % 5;
  if (rest_from <= rest_to) {
    from += rest_to - rest_from;
    return (rest_to - rest_from) * c + (to - from) / 5 * b;
  } else {
    from += rest_to - rest_from + 5;
    return (rest_to - rest_from + 5) * c + (to - from) / 5 * b;
  }
}
void solve() {
  vector<long long> a;
  cin >> n >> k >> b >> c;
  b = min(b, 5 * c);
  a.resize(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<vector<long long>> check_vals(5);
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < 5; ++j) {
      long long cur = (a[i] + j) % 5;
      if (cur < 0) {
        cur += 5;
      }
      check_vals[cur].push_back(a[i] + j);
    }
  }
  long long ans = 4e18 + 5;
  for (long long i = 0; i < 5; ++i) {
    sort(check_vals[i].begin(), check_vals[i].end());
    vector<queue<long long>> vals(5);
    long long cur_sum = 0;
    long long cur_cnt = 0;
    long long last = -2e9 - 10;
    long long uk = 0;
    for (long long candy : check_vals[i]) {
      if (last > -2e9) {
        cur_sum += cur_cnt * (candy - last) / 5 * b;
      }
      last = candy;
      while (uk < a.size() && a[uk] <= candy) {
        vals[((a[uk] % 5) + 5) % 5].push(a[uk]);
        ++cur_cnt;
        cur_sum += dist(a[uk], candy);
        ++uk;
      }
      while (cur_cnt > k) {
        long long erase_from = -1;
        long long max_dist = -1;
        for (long long j = 0; j < 5; ++j) {
          if (!vals[j].empty()) {
            long long cur_dist = dist(vals[j].front(), candy);
            if (cur_dist > max_dist) {
              max_dist = cur_dist;
              erase_from = j;
            }
          }
        }
        --cur_cnt;
        cur_sum -= dist(vals[erase_from].front(), candy);
        vals[erase_from].pop();
      }
      if (cur_cnt >= k) {
        ans = min(ans, cur_sum);
      }
    }
  }
  cout << ans << "\n";
}
