Array of the Year

0

0 votes
Medium
Problem

As the year 2k17 is going to end . Its time to select an Array of the Year . Strongest array will be selected for the award .

You are given an array of n numbers 1 <= n <= 105

  1 . A perfect number Ap is a number which follows this condition Ai < Ap for all i in range [1,p)

  2 . Strength of perfect number is defined as place of that perfect number in array

  3 . Strength of array is defined as the strength of the strongest perfect number in that array

Array with maximum strength will be selected for the award. To take part in the contest array has to pay a fee by deleting one element from it .
suppose an array is {2,3,5,6,1,5} and it deletes 2nd element then the new array will be {2,5,6,1,5}

now your are given an array A (A1, A2, A3 ... An) 1 < = Ai <= 106

you have to delete 1 number from that array

but the condition is that the strength of array should be maximum possible after deleting the number

if there are multiple answers possible delete the smallest number

INPUT
first line of input is a single number t, number of test cases
first line of each test case will be a single number n the length of array
second line of each test case will contain n space separated integers

OUTPUT
output a single number as the number which is to be deleted

CONSTRAINTS
1<=t<=100
1<=n<=105
1<=Ai<=106

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?