In a universe beyond our own, known as the Pancake Universe, there are N breakfast shops. The coordinates of the i-th breakfast shop are (xi, yi).
The residents of the Pancake Universe have a fondness for pancakes. To facilitate a pancake exchange conference, they have decided to set up pancake teleportation gates between the breakfast shops. Specifically, there is a cost of (xi - xj)2 + (yi - yj)2 to set up a gate between the i-th and j-th breakfast shops. Once a gate is set up between two shops, the i-th shop can instantly teleport pancakes to the j-th shop, and vice versa. Once a teleportation gate is built, it can be used any number of times.
Due to financial constraints in the Pancake Universe, please help them calculate the minimum total cost required to ensure that all N breakfast shops can transport pancakes to any other shop through a series of teleportation gates.
The first line contains a positive integer N.
Following that, there are N lines, each containing two integers xi and yi.
There could be different shops located at the same coordinates. ((xi, yi) = (xj, yj), i ≠ j)
Output the answer in one line.