#c22508. Restorer Distance
Restorer Distance
Restorer Distance
Problem Source
CF 1355E
Problem Description
You are given numbers . You need to perform some operations to make all of them equal. The operations are:
- Increase any number by , at cost ;
- Decrease any number by , at cost ;
- Decrease one number by and increase another number by , at cost .
What is the minimum total cost to make all numbers equal?
Input Format
The first line contains 4 integers .
The next line contains integers .
Output Format
One line containing an integer: the minimum cost.
Sample Input
3 1 100 100
1 3 8
Sample Output
12
Constraints
For of the data, $1 \leq N \leq 10^5, 0 \leq A, R, M \leq 10^4, 0 \leq a_i \leq 10^9$.