# Wi Know

You are the boss of Wi Know, an upstanding company in information theory, especially in message encryption.

The counter-counter-intelligence branch of your upstanding company managed to intercept a message sent by the counter-intelligence agency of the local Helsinkian government. This message is, of course, of utmost importance, and its content can probably be used for the “greater good” later. The message is a sequence $S$ of $N$ positive integers not greater than $N$, indexed from $1$ to $N$. Let $S_ i$ be the $i^\textrm {th}$ integer of $S$.

As the first step to mine useful information from this message, you first have to find patterns in it. At the moment, the pattern we’re interested in is whether there exists two different integers $A$ and $B$ such that the pattern $A, B, A, B$ appears as a (not necessarily contiguous) subsequence of the original message. That is, whether there exists four indices $1 \le c < d < e < f \le N$ such that $S_ c = S_ e$, $S_ d = S_ f$, and $S_ c \not= S_ d$.

Your task is to find such a pattern, if any, and print both $A$ and $B$. If there are multiple such pairs $(A, B)$, find the lexicographically smallest one. That is, if there are multiple such pairs $(A, B)$, print the one whose $A$ is minimized. If there are still multiple such patterns, print the one whose $B$ is minimized.

## Input

The first line contains a non-negative integer $4 \leq N \leq 400\, 000$, giving the number of integers in $S$. Thereafter follow $N$ lines, the $i^\textrm {th}$ line contains a single integer $1 \le S_ i \le N$.

## Output

If $A \not= B$ exists and the pattern $A, B, A, B$ appears as a subsequence of $S$, you should print two integers $A$ and $B$ on a single line separated by a single space, denoting the lexicographically smallest pair of $(A, B)$ as described in the problem statement. Otherwise, if there is no such pair, you should print a single integer $-1$.

Sample Input 1 Sample Output 1
8
1
3
2
4
1
5
2
4

1 2

Sample Input 2 Sample Output 2
8
1
2
3
4
5
6
7
1

-1


Sample Input 3 Sample Output 3
4
2
1
2
1

2 1
{"ft_lang_label":"__label__en","ft_lang_prob":0.81853646,"math_prob":0.99745214,"size":2083,"snap":"2020-10-2020-16","text_gpt3_token_len":606,"char_repetition_ratio":0.10918711,"word_repetition_ratio":0.04071247,"special_character_ratio":0.2962074,"punctuation_ratio":0.11085973,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99913186,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-04-08T19:13:07Z\",\"WARC-Record-ID\":\"<urn:uuid:d5f7e5b9-1205-45c8-a2af-340fc297c53a>\",\"Content-Length\":\"19031\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:197ca6d2-bfe8-484c-bf0d-eb2eb1f616cf>\",\"WARC-Concurrent-To\":\"<urn:uuid:02c1f990-23cc-482a-8798-60ebf3303fe4>\",\"WARC-IP-Address\":\"104.26.13.234\",\"WARC-Target-URI\":\"https://purdue.kattis.com/problems/wiknow\",\"WARC-Payload-Digest\":\"sha1:TNVN7NMNLUJKV6MTQ66IGXZ3N5USSO6T\",\"WARC-Block-Digest\":\"sha1:4KKEMW7ZIS7PC65FABTMBSKN2EOYJCYB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585371821680.80_warc_CC-MAIN-20200408170717-20200408201217-00323.warc.gz\"}"}