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

~/algor $ cat problems/minmax-25-qoshnilar-yigindisi-eng-kattasi

Largest sum of an adjacent pair

Easy 1000 ms 128 MB 32%
Share

A positive integer $N$ and $N$ integers are given. Among the sums of two adjacent elements $A_{i} + A_{i + 1}$ ($1 \le i \lt N$), find the largest one and the first $i$ at which it is reached.

Choosing the largest among the sums of adjacent pairs

Input

The first line contains a positive integer $N$. The next line contains $N$ integers $A_{i}$.

Output

One line with two integers separated by a space: the largest sum and the first such $i$.

Note

$2 \le N \le 1000$
$-10^{9} \le A_{i} \le 10^{9}$

Examples

Input #1
6
3 8 2 9 1 5
Output #1
11 1
Input #2
2
-4 -6
Output #2
-10 1

Sign in to submit a solution

Signing up is free and takes a minute.