#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
struct aa {
  int x, d;
  aa(int x = 0, int d = 0) : x(x), d(d) {}
};
queue<aa> q;
int n, k, a[N], dp[2200], used[2200], b[N], tot;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &b[i]);
    b[i] = b[i] - n;
    if (b[i] + n <= 1000 && !used[b[i]]) {
      used[b[i]] = 1;
      a[++tot] = b[i];
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  q.push(aa(1000, 0));
  while (!q.empty()) {
    aa o = q.front();
    q.pop();
    if (o.x == 1000 && dp[1000] != dp[2010]) break;
    for (int i = 1; i <= tot; i++)
      if (a[i] <= 1000) {
        if (o.x + a[i] <= 2000 && o.x + a[i] >= 0 && dp[o.x + a[i]] > o.d + 1) {
          dp[o.x + a[i]] = o.d + 1;
          q.push(aa(o.x + a[i], o.d + 1));
        }
      }
  }
  if (dp[1000] == dp[2010]) dp[1000] = -1;
  printf("%d\n", dp[1000]);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
