#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
int n, k, f[1005];
int main() {
  while (scanf("%d%d", &k, &n) != EOF) {
    memset(f, 0, sizeof(f));
    bitset<2001> dp[2];
    for (int i = 1, t; i <= n; i++) {
      scanf("%d", &t);
      f[t] = 1;
    }
    dp[0][1000] = 1;
    int now = 0;
    for (int i = 1; i <= 1000; i++) {
      now = 1 - now;
      dp[now].reset();
      for (int j = 0; j <= 1000; j++)
        if (f[j]) dp[now] |= (dp[1 - now] << j) >> k;
      if (dp[now][1000]) {
        printf("%d\n", i);
        goto eg;
      }
    }
    puts("-1");
  eg:;
  }
  return 0;
}
