#include <bits/stdc++.h>
using namespace std;
int get() {
  int x = 0;
  char s = getchar();
  while (s < '0' || s > '9') s = getchar();
  while (s >= '0' && s <= '9')
    x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();
  return x;
}
int d[2005], n, k;
queue<int> q;
int main() {
  n = get(), k = get();
  memset(d, 0x3f, sizeof d);
  for (int i = 1, a; i <= k; ++i) d[get() - n + 1000] = 1;
  for (int i = 0; i <= 2000; ++i)
    if (d[i] == 1) q.push(i);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (int i = 0; i <= 2000; ++i)
      if (d[i] == 1 && d[t + i - 1000] == 0x3f3f3f3f)
        q.push(t + i - 1000), d[t + i - 1000] = d[t] + 1;
  }
  if (d[1000] == 0x3f3f3f3f)
    printf("-1");
  else
    printf("%d", d[1000]);
  return 0;
}
