#include
#include
#include
#include
using namespace std;
int f[20005];
int main () {
int v,n;
scanf ("%d%d",&v,&n);
memset (f,-1,sizeof (f));
f[0]=0;
for (int i=1;i<=n;i++) {
int q;
scanf ("%d",&q);
for (int j=v;j>=q;j--) {
if (f[j-q]==-1) continue;
f[j]=j;
}
}
for (int i=0;i