#include <bits/stdc++.h>
using namespace std;
vector<bool> to, u;
vector<int> d;
int main() {
  int n, k, i, a;
  queue<int> q;
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  to.resize(2100);
  u.resize(2100);
  d.resize(2100);
  for (i = 0; i < k; i++) {
    cin >> a;
    to[a - n + 1000] = true;
  }
  q.push(1000);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (i = 0; i <= 2000; i++)
      if (to[i]) {
        int cur = v + i - 1000;
        if (cur < 0 || cur > 2000 || u[cur]) continue;
        u[cur] = true;
        d[cur] = d[v] + 1;
        q.push(cur);
      }
    if (u[1000]) break;
  }
  if (u[1000])
    cout << d[1000];
  else
    cout << -1;
  return 0;
}
