#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
int INF = 1e9;
int n, k, a[1000005];
unordered_map<int, int> d;
int solve() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) cin >> a[i], a[i] -= n;
  sort(a, a + k);
  k = unique(a, a + k) - a;
  for (int i = -1000; i <= 1000; i++) d[i] = INF;
  queue<int> q;
  q.push(0);
  d[0] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int j = 0; j < k; j++) {
      int v = u + a[j];
      if (v > 1000 || v < -1000) continue;
      if (d[v] == INF) {
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
  int ans = INF;
  for (int j = 0; j < k; j++) {
    int v = -a[j];
    if (v > 1000 || v < -1000) continue;
    ans = min(d[v], ans);
  }
  cout << (ans == INF ? -1 : ans + 1) << endl;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  solve();
  return 0;
}
