Under construction

Still being built. Things may change

Candies

Interview

Time limit1sMemory limit1024 MB

Summary
Given n counts and a bonus of up to y for bobo 1, find the most candies bobo 1 can hold after m rounds, where each round the minimum (ties to the smallest label) gets x.
Level

Medium5 of 10

Topics
Heap, Simulation, Greedy
Solved
No attempts yet

Problem

nn bobo are playing a game about candies. The bobo are labeled 1,2,…,n1, 2, \dots, n for convenience. Initially, the ii-th bobo holds aia_i candies.

The game is played in mm rounds. In each round, the bobo with the fewest candies is awarded xx candies. If two or more bobo have the same number of candies, the bobo with the smallest label gets the prize.

The 1st bobo is their leader. Before the game starts, he can receive up to yy more candies from some unknown source. Find the maximum number of candies he can have after the mm rounds.

Input

The first line contains four integers nn, mm, xx, yy (1≤n,m≤2000001 \leq n, m \leq 200000, 1≤x,y≤1091 \leq x, y \leq 10^9).

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \leq a_i \leq 10^9).

Output

Print a single integer: the maximum number of candies the 1st bobo can have after the mm rounds.

Examples1

  1. Example 1

    Input
    2 1 2 2
    1 2
    
    Expected output
    4