why timeout in packaging cupcakes?

n = int(input())

list1 = []

for i in range(n):

a = int(input())
list1.append(a)

for i in range(0,n):

c,pack = 0,0

for j in range(1,list1[i]+1):
    c = list1[i]%j

    if c>pack:

        pack = c

left = list1[i]-pack
print(left)