#include <bits/stdc++.h>
using namespace std;
int n, k;
int visto[1001];
vector<int> lista;
int dist[1001];
int llega[1001];
queue<int> q;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    visto[x] = 1;
  }
  for (int i = 0; i <= 1000; i++) {
    if (visto[i]) {
      if (i == n) {
        printf("1\n");
        exit(0);
      }
      q.push(i);
      llega[i] = 1;
      dist[i] = 1;
      lista.push_back(i - n);
    }
  }
  while (not q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < int(lista.size()); i++) {
      int add = lista[i];
      int v = u + add;
      if (0 <= v and v <= 1000 and not llega[v]) {
        dist[v] = dist[u] + 1;
        llega[v] = 1;
        q.push(v);
        if (v == n) {
          printf("%d\n", dist[v]);
          exit(0);
        }
      }
    }
  }
  printf("-1\n");
}
