#include <bits/stdc++.h>
using namespace std;
int n, k, a[1000005];
map<int, int> m;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) scanf("%d", &a[i]);
  sort(a + 1, a + k + 1);
  k = unique(a + 1, a + k + 1) - (a + 1);
  for (int i = 1; i <= k; i++) a[i] -= n;
  queue<int> que;
  que.push(0);
  m[0] = 0;
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = 1; i <= k; i++) {
      int y = a[i] + x;
      if (y > 1000 || y < -1000) break;
      if (y == 0) return 0 * printf("%d\n", m[x] + 1);
      if (!m[y]) {
        que.push(y);
        m[y] = m[x] + 1;
      }
    }
  }
  printf("-1\n");
  return 0;
}
