#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 * 100;
long long t[MAXN];
vector<long long> who[5], que[5];
int n, k;
long long b, c;
long long get_sum(long long *sum, long long l, long long r) {
  if (l == 0) {
    return sum[r];
  }
  return sum[r] - sum[l - 1];
}
long long g_val = 0;
long long cost(long long l, long long r) {
  long long ans = 0;
  while ((r - l) % 5 != 0) {
    l++;
    ans += c;
  }
  return ans + (r - l) / 5 * b;
}
bool cmp(const long long &a, const long long &b) {
  return (cost(a, g_val) < cost(b, g_val));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> b >> c;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    t[i] += 2 * 1000 * 1000 * 1000;
    who[t[i] % 5].push_back(t[i]);
    for (int j = 0; j < 5; j++) {
      que[(t[i] + j) % 5].push_back(t[i] + j);
    }
  }
  for (int j = 0; j < 5; j++) {
    sort(who[j].begin(), who[j].end());
    sort(que[j].begin(), que[j].end());
  }
  b = min(b, 5 * c);
  long long ans = (long long)1e18;
  for (int j = 0; j < 5; j++) {
    int l[5] = {0, 0, 0, 0, 0};
    int r[5] = {0, 0, 0, 0, 0};
    int cnt = 0;
    long long cur_ans = 0;
    long long la = 0;
    for (long long cur_g_val : que[j]) {
      g_val = cur_g_val;
      cur_ans += (g_val - la) / 5 * cnt * b;
      for (int i = 0; i < 5; i++) {
        while (r[i] < ((int)(who[i].size())) && who[i][r[i]] <= g_val) {
          cur_ans += cost(who[i][r[i]], g_val);
          r[i]++;
          cnt++;
        }
      }
      while (cnt > k) {
        int ind = 0;
        while (l[ind] == r[ind]) {
          ind++;
        }
        for (int i = 0; i < 5; i++) {
          if (l[i] < r[i] && cmp(who[ind][l[ind]], who[i][l[i]])) {
            ind = i;
          }
        }
        cnt--;
        cur_ans -= cost(who[ind][l[ind]], g_val);
        l[ind]++;
      }
      la = g_val;
      if (cnt == k) {
        ans = min(ans, cur_ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
