I have checked if there is any kind of worst case input, as described above, present in test data using the following code.
for test in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
if len(set(l)) == 1 and n >= 2 * 10**4:
raise ValueError("Worst case input")
I got WA instead of RTE. It is clear that such input doesn’t exist in test data.