#include <bits/stdc++.h>
using namespace std;
const int MAX = (const int)(1e6 + 11);
static void solve(std::int32_t test) {
  int N, K;
  set<int> all;
  cin >> N >> K;
  for (int i = 0; i < K; ++i) {
    int x = 0;
    cin >> x;
    all.insert(x);
  }
  map<int, int> D;
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()) {
    auto u = Q.front();
    Q.pop();
    for (const auto &x : all) {
      auto w = u + x - N;
      if (w > 1000 || w < -1000) continue;
      if (w == 0) {
        cout << D[u] + 1;
        return;
      }
      if (D.count(w)) continue;
      D[w] = D[u] + 1;
      Q.push(w);
    }
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout << setprecision(12) << fixed;
  solve(0);
  return 0;
}
