Bear and Contribution

Codeforces is a wonderful platform and one its feature shows how much someone contributes to the community. Every registered user has contribution — an integer number, not necessarily positive. There are n registered users and the i-th of them has contribution t i.

Limak is a little polar bear and he’s new into competitive programming. He doesn’t even have an account in Codeforces but he is able to upvote existing blogs and comments. We assume that every registered user has infinitely many blogs and comments.

  • Limak can spend b minutes to read one blog and upvote it. Author’s contribution will be increased by 5.
  • Limak can spend c minutes to read one comment and upvote it. Author’s contribution will be increased by 1.

Note that it’s possible that Limak reads blogs faster than comments.

Limak likes ties. He thinks it would be awesome to see a tie between at least k registered users. To make it happen he is going to spend some time on reading and upvoting. After that, there should exist an integer value x that at least k registered users have contribution exactly x.

How much time does Limak need to achieve his goal?

Input

The first line contains four integers nkb and c (2 ≤ k ≤ n ≤ 200 000, 1 ≤ b, c ≤ 1000) — the number of registered users, the required minimum number of users with the same contribution, time needed to read and upvote a blog, and time needed to read and upvote a comment, respectively.

The second line contains n integers t 1, t 2, …, t n (|t i| ≤ 109) where t i denotes contribution of the i-th registered user.

Output

Print the minimum number of minutes Limak will spend to get a tie between at least k registered users.

Examples

input

4 3 100 30
12 2 6 1

output

220

input

4 3 30 100
12 2 6 1

output

190

input

6 2 987 789
-8 42 -4 -65 -8 -8

output

0

Note

In the first sample, there are 4 registered users and Limak wants a tie between at least 3 of them. Limak should behave as follows.

  • He spends 100 minutes to read one blog of the 4-th user and increase his contribution from 1 to 6.
  • Then he spends 4·30 = 120 minutes to read four comments of the 2-nd user and increase his contribution from 2 to 6 (four times it was increaded by 1).

In the given scenario, Limak spends 100 + 4·30 = 220 minutes and after that each of users 2, 3, 4 has contribution 6.

In the second sample, Limak needs 30 minutes to read a blog and 100 minutes to read a comment. This time he can get 3 users with contribution equal to 12 by spending 100 + 3·30 = 190 minutes:

  • Spend 2·30 = 60 minutes to read two blogs of the 1-st user to increase his contribution from 2 to 12.
  • Spend 30 + 100 minutes to read one blog and one comment of the 3-rd user. His contribution will change from 6 to 6 + 5 + 1 = 12.

Solution:

#include <bits/stdc++.h>

using namespace std;

const int N = 1234567;

int t[N], r[N], cost[N], nt[N];

int main() {
int n, k, B, C;
scanf("%d %d %d %d", &n, &k, &B, &C);
B = min(B, 5 * C);
for (int i = 0; i < n; i++) {
    scanf("%d", t + i);
  }
  sort(t, t + n);
  for (int i = 0; i < n; i++) {
    r[i] = (t[i] % 5 + 5) % 5;
  }
  long long ans = (long long) 9e18;
  for (int rot = 0; rot < 5; rot++) {
    for (int i = 0; i < n; i++) {
      int shift = (rot - r[i] + 5) % 5;
      cost[i] = C * shift;
      nt[i] = t[i] + shift;
    }
    long long add = 0;
    long long total = 0;
    multiset <long long> s;
for (int i = 0; i < n; i++) {
      if (i > 0 && nt[i] > nt[i - 1]) {
long long value = ((nt[i] - nt[i - 1]) / 5) * 1LL * B;
add += value;
total += value * (long long) s.size();
}
s.insert(cost[i] - add);
total += cost[i];
while ((int) s.size() > k) {
long long z = *(--s.end());
total -= (z + add);
s.erase(--s.end());
}
if (s.size() == k) {
ans = min(ans, total);
}
}
}
cout << ans << endl;
  return 0;
}