Why am I getting TLE 2.01 seconds everytime even after making changes again and again in MULTHREE

cook your dish here

for i in range(int(input())):
inp = list(map(int,input().split()))
lim=inp[0]
inp.pop(0)
for j in range(lim-2):
inp.append(sum(inp)%10)
if sum(inp)%3==0:
print(“YES”)
else:
print(“NO”)

because your algo is not efficient enough to solve the problem in given time limit!!!