#include <bits/stdc++.h>
using namespace std;
long long t_max = 1000000007;
long long MAXX = 1000000000000000000;
long long binpow(long long a, long long n, long long k) {
  long long res = 1;
  while (n)
    if (n & 1) {
      res *= a;
      res %= k;
      n--;
    } else {
      a *= a;
      a %= k;
      n >>= 1;
    }
  return res;
}
struct tree {
  int l, r;
};
bool arr[1001];
int n;
vector<int> v;
int p[1001];
int bfs() {
  queue<int> q;
  for (auto et : v) {
    if (et < 0) continue;
    p[et] = 1;
    q.push(et);
  }
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    if (s == 0) return p[s];
    for (auto et : v) {
      if (et + s >= 0 && p[et + s] == 0) {
        q.push(et + s);
        p[et + s] = p[s] + 1;
      }
    }
  }
  return -1;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  std::ios_base::sync_with_stdio(0);
  bool c1 = 0, c2 = 0, c3 = 0;
  int k, a;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> a;
    if (arr[a] == 1) continue;
    v.push_back(a - n);
    arr[a] = 1;
    if (a > n) c1 = 1;
    if (a == n) c2 = 1;
    if (a < n) c3 = 1;
  }
  if (c2 == 1) {
    cout << 1;
    return 0;
  }
  if (!c1 || !c3) {
    cout << -1;
    return 0;
  }
  cout << bfs();
}
