How to get mode of any list in python?

T=int(input())
for tc in range(T):
N=int(input())
A=list(map(int,input().split(" ")))
l=[A.count(i) for i in set(A)]

print(max(l))

I have used this approach . Why its execution is beyond time limit?
Please help.