cho.sh
Notes
Loading...

Two-Dimensional Vectors

Time limit

2s

Memory limit

128 MB

Problem

A two-dimensional vector is written as (x, y). The sum of vectors (x_1, y_1), (x_2, y_2), ..., (x_n, y_n) is (x_1 + x_2 + ... + x_n, y_1 + y_2 + ... + y_n). In this problem, the size of a vector (x, y) is defined as x^2 + y^2.

You are given N vectors on a plane. Choose any number of them so that the size of the sum vector of the chosen vectors is as large as possible.

Input

The first line contains the number of vectors N (1 <= N <= 30,000). Each of the next N lines contains the coordinates x y of one vector, separated by a space.

Each coordinate is an integer whose absolute value does not exceed 30,000, and (0, 0) is not given as an input vector.

Output

Print the maximum possible size of the sum vector of the chosen vectors.