#include <bits/stdc++.h>
using namespace std;
bool mark[1001];
int nodes[2002];
int main() {
  std::ios_base::sync_with_stdio(false);
  int i, j, n, k;
  cin >> n >> k;
  std::vector<int> edges;
  for (i = 0; i < k; i++) {
    cin >> j;
    if (!mark[j]) {
      mark[j] = 1;
      edges.push_back(j - n);
    }
  }
  for (i = 0; i < 2002; i++) nodes[i] = -1;
  nodes[0 + 1000] = 0;
  queue<int> q;
  q.push(0);
  int ans = -1, u, v;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (auto it = edges.begin(); it != edges.end(); it++) {
      v = u + (*it);
      if (v == 0) {
        ans = nodes[u + 1000] + 1;
        break;
      } else {
        if (nodes[v + 1000] == -1) {
          nodes[v + 1000] = nodes[u + 1000] + 1;
          q.push(v);
        }
      }
    }
    if (ans != -1) break;
  }
  cout << ans;
  return 0;
}
