#include <bits/stdc++.h>
using namespace std;
const int inf = 2009000999;
const double eps = 1e-3;
const int maxn = 2e3 + 55;
const int maxk = 55;
const int base = 1e9 + 7;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
string itosm(long long x) {
  if (x == 0) return "0";
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
int dp[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  ;
  int n, k;
  cin >> k >> n;
  vector<int> c;
  for (int i = 0; i <= maxn; i++) dp[i] = inf;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (dp[a - k + 1000] == inf) c.push_back(a - k + 1000);
    dp[a - k + 1000] = 1;
  }
  int ii;
  for (int i = 0; i < c.size(); i++) {
    ii = i;
    i = c[i];
    if (dp[i] != inf) {
      for (int j = 0; j < c.size(); j++) {
        if (j == ii) continue;
        int jj = j;
        j = c[j];
        if ((j > 1000) == (i > 1000)) {
          j = jj;
          continue;
        }
        if (dp[i + j - 1000] == inf) c.push_back(i + j - 1000);
        dp[i + j - 1000] = min(dp[i + j - 1000], dp[i] + dp[j]);
        j = jj;
      }
    }
    i = ii;
  }
  if (dp[1000] == inf) dp[1000] = -1;
  cout << dp[1000];
  return 0;
}
