#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)5e5 + 228;
const char nxtl = '\n';
const int mod = (int)1e9 + 7;
const double eps = (double)1e-7;
template <typename T>
inline bool updmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool updmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int C = 1000, n, a[MAXN * 2], k, ok[1010];
queue<int> q;
unordered_map<int, int> dp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> a[i];
    if (!ok[a[i]]) {
      q.push(n - a[i]);
      dp[n - a[i]] = 1;
    }
    ok[a[i]] = 1;
  }
  while (!q.empty() && !dp[0]) {
    int cur = q.front();
    q.pop();
    for (int i = 0; i <= 1000; ++i) {
      if (!ok[i]) continue;
      if (cur + (n - i) >= -1000 && cur + (n - i) <= 1000)
        if (!dp[cur + (n - i)]) {
          dp[cur + (n - i)] = dp[cur] + 1;
          q.push(cur + (n - i));
        }
    }
  }
  if (!dp[0]) dp[0] = -1;
  cout << dp[0] << nxtl;
  return 0;
}
