d=int(input)
w=int(input()
h=[]
for i in range(w):
h.append(int(input())
s=[]
while true:
s.append(h[random.randint(1,len(w))]) if sum(s)==d: break