#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int n, k, a[maxn], d[maxn * 2];
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    int t;
    scanf("%d", &t);
    a[t] = 1;
  }
  memset(d, -1, sizeof(d));
  queue<int> que;
  for (int i = 0; i < maxn; ++i) {
    if (a[i]) {
      d[i - n + maxn] = 1;
      que.push(i - n);
    }
  }
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    if (now == 0) break;
    for (int i = 0; i < maxn; ++i) {
      if (a[i] && abs(now + i - n) < maxn && d[now + i - n + maxn] == -1) {
        d[now + i - n + maxn] = d[now + maxn] + 1;
        que.push(now + i - n);
      }
    }
  }
  cout << d[maxn] << endl;
  return 0;
}
