#CCBCHBAHAI0000105. Chỉ số nhỏ nhất và lớn nhất trong cùng một lượt

Chỉ số nhỏ nhất và lớn nhất trong cùng một lượt

Minimum and Maximum Indices in One Scan

Source: Phuoc Hung OJ

Version: Phuoc Hung OJ Extended

Problem

Given A=(a0,…,an−1)A=(a_0,\ldots,a_{n-1}), let m=min⁡aim=\min a_i and M=max⁡aiM=\max a_i. Find

$$i_{\min}=\min\{i\mid a_i=m\},\qquad i_{\max}=\min\{i\mid a_i=M\}.$$

Thus ties are resolved by the smallest 0-based index. Find both extrema and both indices in one scan.

Input

The first line contains nn. The second line contains the nn integers.

Output

Print min_value min_index max_value max_index.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10.

Subtask 2 (30 points): 1≤n≤1001\le n\le100.

Subtask 3 (50 points): 1≤n≤10001\le n\le1000.

Example

Input

6
5 -2 9 -2 9 1

Output

-2 1 9 2

Explanation

The first minimum is at index 1 and the first maximum is at index 2.