#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)5e5 + 228;
const char nxtl = '\n';
const int mod = (int)1e6 + 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 n, a[MAXN * 2], k;
int ok[1010];
bitset<(int)1e6> dp, dp1;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    int x;
    scanf("%d", &x);
    dp[x] = 1;
    ok[x] = 1;
  }
  if (n == 0) {
    if (!ok[0]) {
      cout << -1;
      return 0;
    }
  }
  int res = mod;
  for (int i = 1; i <= 1010; ++i) {
    if (dp[n * i]) {
      cout << i << nxtl;
      return 0;
    }
    dp1.reset();
    for (int j = 0; j <= 1000; ++j) {
      if (ok[j]) {
        dp1 |= (dp << j);
      }
    }
    dp = dp1;
  }
  cout << -1;
  return 0;
}
