t = int(input())

for i in range(t):

n = int(input())

arr = [int(x) for x in input().split()]

ans = 0

for j in range(n):

count = 0 # Reset count for the current element

for k in range(n):

if arr[j] == arr[k]:

count += 1

```
if count > ans:
ans = count
fans=n-count
print(fans)
```

Hi @ajeet_singh09

You have not given any space after for loop

Well, there are some issues with your code, I am looking some syntax errors with your code.

Can you try below code and I am sure it can fix your error.

```
t = int(input())
for i in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
# Calculate the frequency of each element
freq = {}
for num in arr:
if num in freq:
freq[num] += 1
else:
freq[num] = 1
# Find the element with the maximum frequency
max_freq = max(freq.values())
# Calculate the number of elements not equal to the element with max frequency
ans = n - max_freq
print(and)
```

Thanks

Indent spaces arenâ€™t given check it out and re arrange the code