why its giving time limit exceeded …plzz suggest…
"def solve(x,y):
a=[]
copy=[]
c3=0
c1=x*(x+1)//2
for i in y:
if i not in a:
a.append(i)
else:
copy.append(i)
if len(copy)!=0:
c2=copy[0]
for i in copy:
if i!=c2:
c3 +=1
count=c1-(len(copy))-c3
else:
count=c1
print((count%(10**9+7)))
try:
t=int(input())
for i in range(t):
x=int(input())
y=list(map(int,input().split()))
solve(x,y)
except:
pass
"