cho.sh
Notes
Loading...

Nth Largest Number

Time limit

1s

Memory limit

12 MB

Problem

An N × N table is filled with N^2 distinct integers. Each number is greater than the number directly above it, so every column increases from top to bottom.

The following table shows one possible table when N = 5.

1279155
13811196
2110263116
4814283525
5220324149

Given such a table, find the Nth largest number among all N^2 numbers.

Input

The first line contains N (1 ≤ N ≤ 1,500). Each of the next N lines contains N integers. Every number written in the table is an integer between -10^9 and 10^9, inclusive.

Output

Print the Nth largest number on the first line.