c=input();input()
d=[0]+[c+1]*c
for e in map(int,raw_input().split()):
 for j in range(e,c+1):d[j]=min(d[j-e]+1,d[j])
print-(d[c]>c)or d[c]