#include <bits/stdc++.h>
using namespace std;
const int MAX_A = 1000;
bool f_base[2 * MAX_A + 1];
int d_base[2 * MAX_A + 1];
int main() {
  int k, n;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    (f_base + MAX_A)[x - n] = 1;
  }
  queue<int> bfs;
  bfs.push(0);
  while (bfs.size()) {
    int t = bfs.front();
    bfs.pop();
    for (int i = -MAX_A; i <= MAX_A; i++)
      if (t + i >= -MAX_A && t + i <= MAX_A && (f_base + MAX_A)[i] &&
          !(d_base + MAX_A)[t + i]) {
        (d_base + MAX_A)[t + i] = 1 + (d_base + MAX_A)[t];
        bfs.push(t + i);
      }
  }
  printf("%d", ((d_base + MAX_A)[0] == 0 ? -1 : (d_base + MAX_A)[0]));
  return 0;
}
