#include <bits/stdc++.h>
using namespace std;
int ans[2010];
bool h[2010];
queue<int> q;
int main() {
  int n, k, i, j, x, xmax, xmin;
  scanf("%d %d", &n, &k);
  memset(h, 0, sizeof(h));
  memset(ans, 0, sizeof(ans));
  xmax = -1;
  xmin = 1010;
  for (i = 1; i <= k; i++) {
    scanf("%d", &x);
    h[x] = 1;
    xmax = max(xmax, x);
    xmin = min(xmin, x);
  }
  if (xmax < n || xmin > n) {
    printf("-1\n");
    return 0;
  }
  while (!q.empty()) q.pop();
  for (i = 0; i <= 1000; i++) {
    if (h[i]) {
      q.push(i - n);
      ans[i - n + 1000] = 1;
    }
  }
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (i = 0; i <= 1000; i++) {
      if (!h[i]) continue;
      j = x + (i - n);
      if (abs(j) > 1000) continue;
      if (ans[j + 1000])
        continue;
      else {
        ans[j + 1000] = ans[x + 1000] + 1;
        q.push(j);
      }
    }
    if (ans[1000]) break;
  }
  printf("%d\n", ans[1000]);
  return 0;
}
