#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
int a[1000006], n, k;
int vis[2006], ans[2006], val[2006];
int main() {
  while (~scanf("%d%d", &k, &n)) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      a[i] -= k;
    }
    sort(a, a + n);
    n = unique(a, a + n) - a;
    memset(vis, 0, sizeof(vis));
    memset(ans, 0, sizeof(ans));
    if (a[0] * a[n - 1] > 0) {
      printf("-1\n");
      continue;
    }
    int top = 1, last = 1;
    for (int i = 0; i < n; i++) {
      val[top++] = a[i];
      vis[a[i] + 1000] = 1;
      ans[a[i] + 1000] = 1;
    }
    while (last != top && !vis[1000]) {
      for (int i = 0; i < n; i++) {
        if (abs(val[last] + a[i]) <= 1000 && !vis[val[last] + a[i] + 1000]) {
          val[top++] = val[last] + a[i];
          vis[val[last] + a[i] + 1000] = 1;
          ans[val[last] + a[i] + 1000] = ans[val[last] + 1000] + 1;
        }
      }
      last++;
    }
    printf("%d\n", vis[1000] ? ans[1000] : -1);
  }
  return 0;
}
