#include <bits/stdc++.h>
using namespace std;
char _;
const int maxN = 200 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 20;
int a[maxN];
vector<int> v[5];
queue<int> t[5];
int ps(int x) { return ((x % 5) + 5) % 5; }
int b, c;
long long get(int x) { return (1LL) * b * (x / 5) + (x % 5) * c; }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k >> b >> c;
  b = min(b, 5 * c);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 5; j++) v[ps(a[i] + j)].push_back(a[i] + j);
  for (int i = 0; i < 5; i++) {
    sort(v[i].begin(), v[i].end());
    v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
  }
  long long ans = (1LL) * mod * mod;
  sort(a, a + n);
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) t[j] = queue<int>();
    long long tmp = 0;
    int st = 0, sz = 0;
    for (int j = 0; j < v[i].size(); j++) {
      while (st < n && a[st] <= v[i][j]) {
        t[ps(a[st])].push(a[st]);
        tmp -= a[st];
        sz++;
        st++;
      }
      while (sz > k) {
        int px = -1;
        for (int k = 0; k < 5; k++)
          if (t[k].size() && (px == -1 || get(v[i][j] - t[k].front()) >
                                              get(v[i][j] - t[px].front())))
            px = k;
        assert(px != -1);
        tmp += t[px].front();
        t[px].pop();
        sz--;
      }
      if (sz < k) continue;
      long long res = tmp;
      for (int k = 0; k < 5; k++)
        res += (1LL) * t[(i - k + 5) % 5].size() * (v[i][j] - k);
      assert(res % 5 == 0);
      res /= 5;
      res *= b;
      for (int k = 0; k < 5; k++)
        res += (1LL) * t[(i - k + 5) % 5].size() * k * c;
      ans = min(ans, res);
    }
  }
  cout << ans << endl;
  return 0;
}
