k=int(input())
s=int(input())
j=[]
for e in range(s):
j.append(int(input())
q=[]
import random
while sum(q)<k:
q.append(j[random.randint(1,len(j)])