Demon has a warehouse and he wants to light up the warehouse by lighting N bulbs on the ceiling. Consider the ceiling as a coordinate axis and Demon knows the X - Y coordinates of the bulbs that need to be put at the ceiling. Now the bulbs need to be connected with each other using wires. Demon wants to know the minimum sum of the square of the length of wires required to connect the bulbs.
Note: If bulb A and B are connected, bulb B and bulb C are connected, then bulb A and C are also connected.
Input Format:
The first line contains an integer N - the number of bulbs needed to light up the warehouse. The next N lines contain two space-separated integers x and y - representing the coordinates of the bulb.
Output Format:
Output the minimum length of wire required to connect the light bulbs.
Constraints:
\(1 \leq N \leq 1000\)
\(0 \leq x, y \leq 1000\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial