In Bytetown, preparations for the annual Great Bitonic Conference are underway. By tradition, there will be m presentations that all take place at exactly the same time. Every presentation is held in identical rooms, and each room holds at most k people. There are always enough rooms for everyone. If a presentation is attended by n people, it needs ⌈n/k⌉ rooms.
The organizers want to maximize their profit: ticket revenue minus the cost of renting rooms. Renting one room (capacity k) costs s. A ticket to presentation i costs ci. Ticket prices are chosen so that filling a room with ⌊k/2⌋ people already yields non-negative profit (it may also be profitable with fewer people). The organizers may cancel any number of reserved tickets in order to increase their profit.
Given the ticket prices, the room capacity, the room cost, and every reservation, compute the maximum profit that can be obtained by cancelling some of the reserved tickets.
Here ⌈x⌉ is the smallest integer not smaller than x, and ⌊x⌋ is the largest integer not greater than x.
The first line contains four integers m, l, k, and s (1≤m≤100, 2≤l≤1,000,000, 2≤k≤400, 1≤s≤1,000): the number of presentations, the number of reservations, the capacity of one room, and the cost of renting one room.
The second line contains m integers c1,…,cm, where ci⋅⌊k/2⌋≥s and ci≤s: the ticket price of each presentation (numbered 1 through m).
Each of the next l lines contains two integers pi and ri (1≤pi≤m, 1≤ri≤1,000): a reservation of ri tickets for presentation pi. Within a single reservation any number of tickets may be cancelled, not only the reservation as a whole.
Print one integer: the maximum profit (ticket revenue minus room-rental cost) the organizers can obtain.
In the first example there are 3 presentations with ticket prices 7, 10, 8, a room capacity of 10, and a room cost of 30. Presentation 1 has 9 reserved tickets, so with one room the profit is 7⋅9−30=33. Presentation 3 has 13 reserved tickets; keeping all 13 would need two rooms, but keeping only 10 (one full room) is more profitable, so 3 tickets are cancelled for a profit of 8⋅10−30=50. The total is 33+50=83.