Tonight, Chef would like to hold a party for his $N$ friends.
All friends are invited and they arrive at the party one by one in an arbitrary order. However, they have certain conditions — for each valid $i$, when the $i$-th friend arrives at the party and sees that at that point, strictly less than $A_i$ other people (excluding Chef) have joined the party, this friend leaves the party; otherwise, this friend joins the party.
Help Chef estimate how successful the party can be — find the maximum number of his friends who could join the party (for an optimal choice of the order of arrivals).

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $A_1, A_2, \ldots, A_N$.

-----Output-----
For each test case, print a single line containing one integer — the maximum number of Chef's friends who could join the party.

-----Constraints-----
- $1 \le T \le 1,000$
- $1 \le N \le 10^5$
- the sum of $N$ over all test cases does not exceed $10^6$

-----Example Input-----
3
2
0 0
6
3 1 0 0 5 5
3
1 2 3

-----Example Output-----
2
4
0

-----Explanation-----
Example case 1: Chef has two friends. Both of them do not require anyone else to be at the party before they join, so they will both definitely join the party.
Example case 2: At the beginning, friends $3$ and $4$ can arrive and join the party, since they do not require anyone else to be at the party before they join. After that, friend $2$ can arrive; this friend would see that there are two people at the party and therefore also join. Then, friend $1$ will also join, so in the end, there would be $4$ people attending the party.
Example case 3: No one will attend the party because each of Chef's friends will find zero people at the party and leave, regardless of the order in which they arrive.

Difficulty: interview

Starter code:

Solutions:
test=int(input())
for _ in range(test):
 n=int(input())
 ls=list(map(int,input().split()))
 ls.sort()
 s=0
 for i in range(n):
  if s>=ls[i]:
   s=s+1
  else:
   break
 print(s)

# cook your dish here
test_case = int(input())
while test_case :
 n = int(input())
 friends_req = list(map(int, input().strip().split()))
 
 friends_req.sort()
 
 current_friends = 0 
 
 for i in range(n) :
  if friends_req[i] <= current_friends :
   current_friends += 1
  else:
   break
 
 print(current_friends)
  
 
 test_case -= 1
 
 
 
 
 
 
 
 
 
 


# cook your dish here
for _ in range(int(input())):
 n=int(input())
 sum=0
 l=[int(item) for item in input().split()]
 l.sort() 
 for i in range(n):
  if l[i]==0:
   sum=sum+1
  elif l[i]<=sum:
   sum=sum+1
 print(sum)


# cook your dish here
t=int(input())
for _ in range(t):
 n = int(input())
 
 a = list(map(int,input().split()))
 a.sort()
 cnt=0
 
 for i in range(n):
  
  if cnt<a[i]:
   break
  
  else:
   cnt+=1
   
 print(cnt)

# cook your dish here
t=int(input())
for z in range(t):
 n=int(input())
 l=map(int,input().split())
 
 tg=0
 for i in sorted(l):
  if(i<=tg):
   tg+=1
 print(tg) 

for i in range(int(input())):
 n = int(input())
 arr = list(map(int,input().split()))
 count = 0
 arr.sort()
 for i in range(n):
  if arr[i] <= count:
   count += 1
  else:
   break
 print(count)

# cook your dish here
t=0
try:
 t=int(input())
except:
 pass

for _ in range(t):
 n = int(input())
 a = list(map(int, input().split()))
 
 a = sorted(a)
 
 already_present = 0
 
 for requirement in a:
  
  if already_present>=requirement:
   already_present+=1
 
 print(already_present)
  
  
  


# cook your dish here
for i in range(int(input())):
 n=int(input())
 arr=list(map(int,input().split()))
 count=0
 arr=sorted(arr)
 for x in range(n):
  if arr[x]<=count:
   count+=1
  else:
   break
 print(count)

def chef_party():
 t = int(input())
 for _ in range(t):
  N = int(input())
  array = input()
  array = array.split()
  array = list(map(int,array))
  num_of_frnds = 0
  array.sort()
  for i in range(N):
   if array[i] <= i:
    num_of_frnds += 1 
   else:
    break
   
  print(num_of_frnds)
  num_of_frnds = 0
  
chef_party()

for _ in range(int(input())):
 n=int(input())
 list1 = list(map(int, input().split()))
 sum = 0
 list1.sort()
 for i in range(len(list1)):
  if list1[i] <= i:
   sum = sum + 1
  else:
   break
 print(sum)



# cook your dish here
for _ in range(int(input())):
 n = int (input())
 arr = list(map(int,input().split()))
 arr.sort()
 c = 0
 for i in range(n):
  
  if arr[i]<= c:
   c+=1

  else:
   break
 print(c)

# cook your dish here
t=int(input())
for i in range(t):
 n=int(input())
 arr=list(map(int,input().split()))
 if 0 not in arr:
  print(0)
 elif arr.count(0)==len(arr):
  print(n)
 else:
  c=0
  arr.sort()
  for k in arr:
   if c>=k:
    c+=1
   else:
    break
  print(c)

for xxx in range(int(input(''))):
 n=int(input(''))
 a=list(map(int,input('').split(' ')))
 a=sorted(a)
 going=0
 for i in a:
  if i==0:
   going+=1 
 while 0 in a:
  a.remove(0)
 for i in range(len(a)):
  current=a[i]
  if going>=current:
   going+=1
   a[i]=-1
 print(going)

for _ in range(int(input())):
 n=int(input())
 ar=[int(x) for x in input().split()]
 ar.sort()
 s=0
 an=0
 for i in range(n):
  if ar[i]<=s:
   s+=1
   an+=1
  else:
   break
 print(an)
   


# cook your dish here
t = int(input())
for _ in range(t) :
 n = int(input())
 arr = list(map(int,input().split()))
 arr.sort()
 c = 0
 for i in range(n) :
  if arr[i] <= c :
   c += 1
  else :
   break
 print(c)

def solve():
 n=int(input())
 l=[]
 l=list(map(int,input().split()))
 l.sort()
 c=0
 if(l[0]==0):
  c=1
 for i in range(1,len(l)):
  if l[i]<=c:
   c+=1
 print(c)

t=int(input())
i=0
while i<t:
 solve()
 i+=1

T = int(input())
ans = []

for _ in range(T):
 N = int(input())
 A = [int(i) for i in input().split()]

 A.sort()
 guest = 0
 for i in range(N):
  if(A[i]<=guest):
   guest += 1
 ans.append(guest)

for i in ans:
 print(i)


for _ in range(int(input())):
 N = int(input())
 A=list(map(int, input().split()))
 A.sort()
 k=0
 for i in range(len(A)):
  if A[i]<=k:
   k+=1
  else:
   pass
 print(k)

# cook your dish here
#import math

t=int(input())
while(t>0):
 t-=1
 n=int(input())
 l=list(map(int,input().split()))
 l.sort()
 ans=0
 for i in range(n):
  if(ans>=l[i]):
   ans+=1
  else:
   break
 print(ans)

for _ in range(int(input())):
 n=int(input())
 a=list(map(int,input().split()))
 a.sort()
 c=0
 for i in range(n):
  if c>=a[i]:
   c+=1
  else:
   break
 print(c)


x=int(input())
for i in range(x):
 friends=int(input())
 arr=list(map(int,input().split()))
 arr.sort()
 tot=0
 for ele in arr:
  if ele<=tot:
   tot+=1
 print(tot)


# cook your dish here
a = int(input())
for i in range(a):
 b = int(input())
 c = list(map(int,str(input()).split(' ')))
 c.sort()
 n = 0
 for j in range(b):
  if int(c[j])<=j:
   n+=1
  else:
   break
 print(n)