FIICode 2024 Elevi | Minimize Damage

This was the problem page during the contest. Access the current page here.
Time limit: 1s
Memory limit: 256MB
Input:
Output:

In Legends of the League, Okke is a character that can control time. His most powerful ability is to reverse damage and healing done to him. Of course, he will use it so that the reduction to his health points is minimized.

Damage and healing events are represented as an array aa of nn integers. Okke will apply the following operation on the array exactly once:

Choose 22 integers ll and rr (1lrn1 \le l \le r \le n) and replace all aia_i (lirl \le i \le r) with ai-a_i.

In the end, he wants the sum of the elements of aa to be as small as possible.

Input

The first line contains a single integer nn (1n1051 \le n \le 10^5) – the length of the array aa.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1000ai1000-1000 \le a_i \le 1000).

Output

Print ll and rr – the indices chosen for the operation.

If there are multiple solutions, print the one that minimizes rr. If there are multiple solutions that minimize rr, print the one that maximizes ll.

Example

stdin

5
3 2 -1 4 -3

stdout

1 4

Notes

After applying the operation for l=1l = 1 and r=4r = 4, the array becomes a=3,2,1,4,3a = \langle -3, -2, 1, -4, -3 \rangle, having the sum 11-11, which is the smallest possible sum.

Contest info

Official contest

Start time: 1710082800000

Total duration: 2h30m0s

Status: Ended

Log in or sign up to be able to send submissions!