Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/nuqtalar-diametri

Diameter of a point set

Hard 2000 ms 128 MB 67%
Share

$n$ points are given on the plane (some may coincide). Find the largest distance between them. To keep the answer an integer, print the square of this distance.

A set of points, its convex hull and the segment joining the two farthest points

Input

The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $x_{i}$ and $y_{i}$.

Output

One integer — the square of the largest distance.

Note

$1 \le n \le 10^{5}$
$-10^{9} \le x_{i}, y_{i} \le 10^{9}$

Examples

Input #1
5
0 0
3 1
1 4
-2 2
1 1
Output #1
26
Input #2
1
7 7
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.