Under construction

Still being built. Things may change

Books

Interview

Time limit1sMemory limit1024 MB

Summary
Pick which books to read in full (a minutes each) and which by cover only (b minutes each) within t minutes to maximize the total attraction of fully read books.
Level

Medium4 of 10

Topics
Greedy, Prefix sum, Array
Solved
No attempts yet

Problem

Marko was at the Interliber book fair, and he bought nn books. The attraction of the ii-th book is kik_i. Marko arranged the books on the shelf according to their attraction values, so the first book from the left is the least attractive, and every next one to the right is at least as attractive as the previous one.

It has been quite some time since Interliber, but Marko has only now found time to read the books. He will spend a total of tt minutes reading.

For each book, he can either read it in its entirety, which takes aa minutes, or read only the content from the covers, which takes bb minutes.

He starts from the leftmost book. After finishing the current book (either entirely or just the content from the covers), he moves on to the next book, which is the first one to the right of the book he just read. Marko's inspiration is the sum of the attraction values of the books he has read in their entirety. What is the maximum value of Marko's inspiration after tt minutes?

Note: If Marko starts reading a book but does not finish it before the end of tt minutes, that book does not contribute to his inspiration.

Input

The first line contains integers nn, tt, aa, and bb (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5, 1≤t≤1091 \le t \le 10^9, 1≤b<a≤1091 \le b < a \le 10^9), the number of books, the time Marko will spend reading, the time required to read a book in its entirety, and the time required to read only the content from the covers.

The second line contains nn integers kik_i (1≤ki≤1091 \le k_i \le 10^9, ki≤ki+1k_i \le k_{i+1}), the attraction values of the books.

Output

Print Marko's maximal inspiration after tt minutes on the first and only line.

Examples3

  1. Example 1

    Input
    3 5 2 1
    2 2 4
    
    Expected output
    6
    
  2. Example 2

    Input
    2 10 3 1
    3 3
    
    Expected output
    6
    
  3. Example 3

    Input
    4 10 3 2
    3 4 5 6
    
    Expected output
    12