#include <bits/stdc++.h>
using namespace std;
const int MAXK = 1000005;
const int MAXN = 1005;
int n, k, a[MAXK], d[2 * MAXN];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &a[i]);
    a[i] -= n;
  }
  sort(a, a + k);
  k = unique(a, a + k) - a;
  memset(d, -1, sizeof d);
  queue<int> q;
  d[1005] = 0;
  q.push(1005);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < k; i++) {
      if (u + a[i] == 1005) {
        printf("%d\n", d[u] + 1);
        return 0;
      }
      if (u + a[i] >= 0 && u + a[i] < 2 * MAXN && d[u + a[i]] == -1) {
        d[u + a[i]] = d[u] + 1;
        q.push(u + a[i]);
      }
    }
  }
  printf("-1\n");
  return 0;
}
