#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > M;
map<int, bool> m;
long ans;
bool bfs() {
  queue<pair<int, long> > q;
  q.push(make_pair(0, 0));
  long c = 0;
  map<int, bool> mp;
  mp[0];
  while (!q.empty()) {
    int a = q.front().first;
    c = q.front().second;
    q.pop();
    for (int i = 0; i < M[a].size(); i++) {
      int v = M[a][i];
      if (v == 0) {
        ans = c + 1;
        return true;
      }
      if (mp.find(v) == mp.end()) {
        q.push(make_pair(v, c + 1));
        mp[v];
      }
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  while (k--) {
    int a;
    cin >> a;
    m[a - n];
  }
  for (int i = -1000; i <= 1000; i++) {
    map<int, bool>::iterator it = m.begin();
    while (it != m.end()) {
      M[i].push_back(i + it->first);
      it++;
    }
  }
  ans = INT_MAX;
  if (bfs())
    cout << ans;
  else
    cout << "-1";
}
