#include <bits/stdc++.h>
using namespace std;
int k, n, x, h, t, p, b[10010], q[10010];
int main() {
  cin >> k >> n;
  for (int i = 0; i <= 10000; i++) {
    b[i] = 2000000000;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    b[x - k + 1000] = 1;
  }
  for (int i = 0; i <= 2000; i++) {
    if (b[i] == 1) {
      q[t] = i;
      t++;
    }
  }
  while (h < t) {
    p = q[h];
    h++;
    for (int i = 0; i <= 2000; i++) {
      if (b[i] == 1 && b[p + i - 1000] == 2000000000) {
        q[t] = p + i - 1000;
        t++;
        b[p + i - 1000] = b[p] + 1;
      }
    }
  }
  if (b[1000] == 2000000000) {
    cout << -1;
  } else {
    cout << b[1000];
  }
  return 0;
}
