#include <bits/stdc++.h>
using namespace std;
unordered_map<int, bool> vis;
bool inputted[(int)2e6];
int n, k;
vector<int> v;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    if (!inputted[x]) v.push_back(x);
    inputted[x] = true;
  }
  for (int i = 0; i < v.size(); i++) v[i] -= n;
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> curr = q.front();
    q.pop();
    if (curr.first == 0 && curr.second != 0) {
      printf("%d\n", curr.second);
      return 0;
    }
    if (vis[curr.first]) continue;
    vis[curr.first] = true;
    for (int i = 0; i < v.size(); i++) {
      if (curr.first > 0 && curr.first + v[i] > curr.first) continue;
      if (curr.first < 0 && curr.first + v[i] < curr.first) continue;
      q.push(make_pair(curr.first + v[i], curr.second + 1));
    }
  }
  printf("-1\n");
}
