#include <bits/stdc++.h>
using namespace std;
vector<string> _split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return v;
}
void _print(vector<string>::iterator) {}
template <typename T, typename... Args>
void _print(vector<string>::iterator it, T a, Args... args) {
  string name = it->substr((*it)[0] == ' ', it->length());
  if (isalpha(name[0]))
    cerr << name << " = " << a << " ";
  else
    cerr << name << " ";
  _print(++it, args...);
}
const int N = (int)1e6 + 100;
const long long int INF = (long long int)1e18;
const long long int SH = 1e9;
int n, k;
long long int b, c;
long long int t[N];
long long int ans;
long long int cost[N];
long long int get_cost(long long int len) {
  assert(len % 5 == 0);
  return min(len * c, (len / 5) * b);
}
bool cmp(int a, int b1) {
  if (cost[a] != cost[b1]) return cost[a] < cost[b1];
  return a < b1;
}
long long int get_dx(long long int cur_t, int r) {
  long long int cur_ans = 0;
  while (cur_t % 5 != r) {
    cur_t += 1;
    cur_ans += 1;
  }
  return cur_ans;
}
void try_solve(int r) {
  long long int T = (long long int)2e9 + r;
  for (int i = 0; i < n; i++) {
    long long int cur_t = t[i];
    long long int dx = get_dx(cur_t, r);
    long long int cur_cost = dx * c + get_cost(T - cur_t - dx);
    cost[i] = cur_cost;
    {
      if (false) {
        _print(_split("cost[i]", ',').begin(), cost[i]);
        cerr << endl;
      } else {
        void(0);
      }
    };
  }
  set<int, decltype(&cmp)> s(&cmp);
  long long int cost_to_T = 0;
  for (int ptr = 0; ptr < n; ptr++) {
    s.insert(ptr);
    cost_to_T += cost[ptr];
    if ((int)s.size() == k + 1) {
      int bad_ind = (*s.rbegin());
      cost_to_T -= cost[bad_ind];
      s.erase(bad_ind);
    }
    long long int x = t[ptr] + get_dx(t[ptr], r);
    if ((int)s.size() == k) {
      {
        if (false) {
          _print(_split("k, cost_to_T, get_cost(T - x), T - x", ',').begin(), k,
                 cost_to_T, get_cost(T - x), T - x);
          cerr << endl;
        } else {
          void(0);
        }
      };
      long long int cur_ans = cost_to_T - get_cost(T - x) * k;
      {
        if (false) {
          _print(_split("cur_ans", ',').begin(), cur_ans);
          cerr << endl;
        } else {
          void(0);
        }
      };
      ans = min(ans, cur_ans);
    }
  }
}
int main() {
  scanf("%d%d%lld%lld", &n, &k, &b, &c);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &t[i]);
    t[i] += SH;
  }
  sort(t, t + n);
  ans = INF;
  for (int r = 0; r < 5; r++) try_solve(r);
  printf("%lld\n", ans);
  return 0;
}
