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

~/algor $ cat problems/minmax-7-birinchi-max-va-oxirgi-min

First maximum and last minimum

Easy 1000 ms 256 MB 25%
Share

A positive integer $N$ and $N$ integers are given. Find the position of the first occurrence of the largest element and the position of the last occurrence of the smallest element.

The positions of the first maximum and the last minimum

Input

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

Output

One line with two integers separated by a space: the position of the first maximum and the position of the last minimum.

Note

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

Examples

Input #1
6
4 8 2 8 2 5
Output #1
2 5
Input #2
5
10 10 1 10 1
Output #2
1 5

Sign in to submit a solution

Signing up is free and takes a minute.