K = int(input())
m = int(input())
a = []
c = []
for i in range (1, K+1):
a.append(i)
for i in range(m):
b = int(input())
c.append(b)
for j in a:
for i in c:
if a[j] % c[i] == 0:
a.remove(a[j])
print(a)
Currently giving me a index out of range error, but I don't see whats wrong with it.