#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int n, k;
int num[MAXN], app[MAXN * MAXN];
int xi[MAXN], tot, inq[MAXN];
void bfs() {
  queue<int> Q;
  memset(app, 10, sizeof app);
  for (int i = 1; i <= tot; i++) {
    if (xi[i] >= 0) Q.push(xi[i]), app[xi[i]] = 1, inq[xi[i]] = 1;
    if (xi[i] == 0) return;
  }
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    inq[v] = 0;
    for (int i = 1; i <= tot; i++) {
      if (v + xi[i] < 0 || app[v + xi[i]] <= app[v] + 1 || inq[v + xi[i]])
        continue;
      app[v + xi[i]] = app[v] + 1;
      if (v + xi[i] == 0) break;
      Q.push(v + xi[i]);
      inq[v + xi[i]] = 1;
    }
  }
}
int main() {
  scanf("%d%d", &k, &n);
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    num[u] = 1;
  }
  for (int i = 0; i <= 1000; i++) {
    if (num[i]) {
      xi[++tot] = i - k;
    }
  }
  bfs();
  printf("%d\n", app[0] > 10000000 ? -1 : app[0]);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
