#include <bits/stdc++.h>
const int MAXN = 1000;
std::vector<int> v;
int n, k, m;
bool vis[MAXN + 5];
int dis[MAXN * 2 + 5];
inline void bfs() {
  std::queue<int> q;
  for (register int i = 0; i <= m; ++i) {
    if (vis[i]) {
      v.push_back(i - n);
      dis[i - n + m] = 1;
      if (i - n + m == m) return;
      q.push(i - n + m);
    }
  }
  while (!q.empty()) {
    for (auto delta : v) {
      int x = q.front() + delta;
      if (x < 0 || x > 2000 || dis[x] <= dis[q.front()] + 1) continue;
      dis[x] = dis[q.front()] + 1;
      if (x == m) return;
      q.push(x);
    }
    q.pop();
  }
}
int main() {
  m = 1000;
  scanf("%d%d", &n, &k);
  memset(dis, 0x3f, sizeof(dis));
  for (register int i = 1; i <= k; ++i) {
    int x;
    scanf("%d", &x);
    vis[x] = true;
  }
  bfs();
  printf("%d\n", dis[m] == 0x3f3f3f3f ? -1 : dis[m]);
  return 0;
}
