#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool readInteger(T& u) {
  char x;
  int aFlag = 1;
  while (!isdigit((x = getchar())) && x != '-' && x != -1)
    ;
  if (x == -1) {
    ungetc(x, stdin);
    return false;
  }
  if (x == '-') {
    aFlag = -1;
    x = getchar();
  }
  for (u = x - '0'; isdigit((x = getchar())); u = u * 10 + x - '0')
    ;
  u *= aFlag;
  ungetc(x, stdin);
  return true;
}
int n, k;
bool exist[1001];
int f[1000 * 2 + 5];
inline void init() {
  readInteger(n);
  readInteger(k);
  memset(exist, false, sizeof(exist));
  for (int i = 1, a; i <= k; i++) {
    readInteger(a);
    exist[a] = true;
  }
}
queue<int> que;
inline void bfs() {
  memset(f, -1, sizeof(f));
  for (int i = 0; i <= 1000; i++) {
    if (exist[i]) {
      f[1000 + i - n] = 1;
      que.push(1000 + i - n);
    }
  }
  while (!que.empty()) {
    int e = que.front();
    que.pop();
    for (int i = 0; i <= 1000; i++) {
      if (!exist[i]) continue;
      int eu = e + i - n;
      if (eu < 0) continue;
      if (eu > 1000 * 2) continue;
      if (f[eu] == -1) {
        f[eu] = f[e] + 1;
        if (eu == 1000) return;
        que.push(eu);
      }
    }
  }
}
inline void solve() {
  if (exist[n]) {
    puts("1");
    return;
  }
  bfs();
  printf("%d", f[1000]);
}
int main() {
  init();
  solve();
  return 0;
}
