#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T>
void printv(const vector<T>& s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, k;
  cin >> n >> k;
  vector<int> a(k);
  for (int i = 0; i < k; ++i) {
    cin >> a[i];
    a[i] -= n;
  }
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  k = (int)(a.size());
  for (int i = 0; i < k; ++i) {
    if (a[i] == 0) {
      cout << 1 << endl;
      return 0;
    }
  }
  vvi g(2001);
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j <= 2000; ++j) {
      if (0 <= a[i] + j && a[i] + j <= 2000) {
        g[j].push_back(a[i] + j);
      }
    }
  }
  int ans = -1;
  bool ok = false;
  queue<P> que;
  que.push({0, 0});
  vector<int> dist(2001, INF);
  vector<bool> sel(2001, false);
  while (!que.empty()) {
    P now = que.front();
    que.pop();
    if (now.second > dist[now.first]) continue;
    dist[now.first] = now.second;
    for (int i = 0; i < (int)(g[now.first].size()); ++i) {
      int nxt = g[now.first][i];
      if (sel[nxt]) continue;
      sel[nxt] = true;
      if (nxt == 0) {
        ok = true;
        break;
      }
      que.push({nxt, now.second + 1});
    }
    if (ok) {
      ans = now.second + 1;
      break;
    }
  }
  cout << ans << endl;
}
