Sequence
题号:NC15931
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

We define an element  in a sequence "good", if and only if there exists  (1≤j<i) such that .

Given a permutation p of integers from 1 to n. Remove an element from the permutation such that the number of "good" elements is maximized.

输入描述:

The input consists of several test cases. The first
line of the input gives the number of test cases,.

For each test case, the first line contains an
integer ,
representing the length of the given permutation.

The second line contains n integersp1,p2,…,pn ,
representing the given permutation p.

It's guaranteed that  .

输出描述:

For each test case, output one integer in a single
line, representing the element that should be deleted. If there are several
answers, output the minimal one.
示例1

输入

复制
2
1
1
5
5 1 2 3 4

输出

复制
1
5