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

~/algor $ cat problems/minmax-3-eng-katta-perimetrli-tortburchak

Rectangle with the largest perimeter

Easy 1000 ms 256 MB 22%
Share

A positive integer $N$ and the sides $a$ and $b$ of each of $N$ rectangles are given. Find the perimeter of the rectangle with the largest perimeter:

$$P = 2 * (a + b)$$

Choosing the rectangle with the largest perimeter among several

Input

The first line contains the number of rectangles $N$. Each of the next $N$ lines contains two integers: $a_{i}$ and $b_{i}$.

Output

One integer — the largest perimeter of a rectangle.

Note

$1 \le N \le 1000$
$1 \le a_{i}, b_{i} \le 10^{4}$

Examples

Input #1
3
3 4
2 7
5 3
Output #1
18
Input #2
2
10 5
8 8
Output #2
32

Sign in to submit a solution

Signing up is free and takes a minute.