#include <bits/stdc++.h>
const int MAX_N = (int)2e5 + 123;
const double eps = 1e-6;
const int inf = (int)1e9 + 123;
using namespace std;
int n, k, b, c;
int t[MAX_N];
pair<int, int> x[MAX_N];
long long ans = (long long)1e18;
multiset<long long> q;
int main() {
  scanf("%d%d%d%d", &n, &k, &b, &c);
  b = min(b, 5 * c);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int mod = 0; mod < 5; mod++) {
    for (int i = 1; i <= n; i++) {
      x[i] = make_pair(t[i], 0);
      while ((x[i].first % 5 + 5) % 5 != mod) {
        x[i].first++;
        x[i].second += c;
      }
    }
    sort(x + 1, x + n + 1);
    q.clear();
    long long add = 0, all = 0;
    for (int i = 1; i <= n; i++) {
      if (i > 1) {
        long long val = (x[i].first - x[i - 1].first) / 5 * 1ll * b;
        all += 1ll * val * int((q).size());
        add += val;
      }
      q.insert(x[i].second - add);
      all += x[i].second;
      if (int((q).size()) > k) {
        auto it = --q.end();
        all -= (*it + add);
        q.erase(it);
      }
      if (int((q).size()) == k) ans = min(ans, all);
    }
  }
  cout << ans;
  return 0;
}
