#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)2e18 + 20;
long long work_rem(const vector<int> &t, int rem, int b, int c, int k) {
  long long total_add = 0;
  const int n = (int)(t).size();
  vector<int> ptr;
  for (int i = 0; i < n; i++)
    for (int s = 0; s < 5; s++)
      if ((t[i] + s + inf) % 5 == rem) ptr.push_back(t[i] + s);
  sort((ptr).begin(), (ptr).end());
  ptr.resize(unique((ptr).begin(), (ptr).end()) - ptr.begin());
  auto dist = [&](int x, int y) -> long long {
    assert(x >= y);
    int diff = x - y;
    return (long long)c * (diff % 5) + (long long)b * (diff / 5);
  };
  multiset<long long> who;
  long long total_sum = 0;
  int j = 0;
  bool was_prev = false;
  int prev = 0;
  long long ans = inf;
  for (int id : ptr) {
    if (!was_prev) {
      was_prev = true;
      prev = id;
    } else {
      int diff = id - prev;
      assert(diff % 5 == 0);
      total_add += (long long)(diff / 5) * b;
      total_sum += (int)(who).size() * (long long)(diff / 5) * (long long)b;
      prev = id;
    }
    while (j < n && t[j] <= id)
      who.insert(dist(id, t[j]) - total_add), total_sum += dist(id, t[j]), j++;
    while ((int)(who).size() > k) {
      total_sum -= total_add + *who.rbegin();
      auto it = who.end();
      --it;
      who.erase(it);
    }
    if ((int)(who).size() == k) ans = min(ans, total_sum);
  }
  return ans;
}
void solve(int n) {
  int k, b, c;
  cin >> k >> b >> c;
  vector<int> t(n);
  for (int i = 0; i < n; i++) cin >> t[i];
  sort((t).begin(), (t).end());
  if (5 * c < b) {
    long long ans = inf;
    long long sumt = 0;
    for (int j = 0; j < k; j++) sumt += t[j];
    for (int j = k - 1; j < n; j++) {
      ans = min(ans, t[j] * (long long)k - sumt);
      sumt -= t[j - (k - 1)];
      if (j != n - 1) sumt += t[j + 1];
    }
    cout << ans * c << endl;
    return;
  }
  long long ans = inf;
  for (int rem = 0; rem < 5; rem++) ans = min(ans, work_rem(t, rem, b, c, k));
  cout << ans << endl;
}
int main() {
  int n;
  while (cin >> n) solve(n);
}
