#include <bits/stdc++.h>
const long long oo = 0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
long long o(long long x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
using namespace std;
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
struct qtype {
  int x, step;
  qtype() {}
  qtype(int x, int step) {
    this->x = x;
    this->step = step;
  }
};
int n, k, x;
set<int> S;
queue<qtype> Q;
map<int, int> M;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &x);
    S.insert(x - n);
  }
  Q.push(qtype(0, 0));
  while (!Q.empty()) {
    x = Q.front().x;
    for (auto t : S) {
      if (abs(x + t) > 10000 || M[x + t]) continue;
      M[x + t] = 1;
      Q.push(qtype(x + t, Q.front().step + 1));
      if (x + t == 0) {
        cout << Q.front().step + 1 << endl;
        return 0;
      }
    }
    Q.pop();
  }
  cout << -1 << endl;
  return 0;
}
