Build Roads
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

In the cat country, there are n cities. The cat country king wants to build n-1 roads to connect all the cities. The i-th city has a construction company with an experience value of a_i. To build a road between the i-th city and the j-th city, the two cities' construction companies need to cooperate with each other. However, in the process of building a road, the two construction companies may have conflicts due to poor communication, and it will result in a waste of building materials. Formally, building a road between the i-th city and the j-th city will waste  building materials.

Can you help the cat country king choose to build n-1 roads that connect all the cities and minimize the waste of building materials?

To decrease the input size, the king of the cat country gives you a random integer generator and 3 parameters L,R,seed. The following C language code shows how to generate n integers , and stores the experience value of the construction company of the i-th city. You can use the code directly in your submissions.

输入描述:

The only line contains four integers n,L,R,seed .

输出描述:

Print one integer -- the minimum waste of connecting all the cities.

示例1

输入

复制
5 1 200000 123

输出

复制
4